The latest detailed steps to configure LNMP centos nginx mysql php7.4

[root@localhost ~]# rpm -Uvh
[root@localhost ~]# rpm -Uvh
[root@localhost ~]# rpm -Uvh
[root@localhost ~]# yum -y install #used to install php7.4
[root@localhost ~]# yum -y install nginx
[root@localhost ~]# yum -y install mysql-community-server
[root@localhost ~]# yum -y install yum-utils
[root@localhost ~]# yum-config-manager –enable remi-php74
The current PHP version should be version 7.4 as follows:
[root@localhost ~]# yum install php php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json
$ php -v
PHP 7.4.0RC1 (cli) (built: Sep 3 2019 07:45:03) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0-dev, Copyright (c) Zend Technologies

If you want to see which modules are enabled, run:
$ php –modules
So far, you have successfully installed PHP 7.4 on CentOS 7
[root@localhost ~]# systemctl start mysqld # boot mysql
[root@localhost ~]# grep ‘temporary password’ /var/log/mysqld.log # find default secret
2017-04-10T02:58:16.806931Z 1 [Note] A temporary password is generated for root@localhost: iacFXpWt-6gJ
# reset secret
[root@localhost ~]# mysql -uroot -p’iacFXpWt-6gJ’
mysql> ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘MyPass1!’;
mysql> set password for ‘root’@’localhost’=password(‘123abc’);

[root@localhost ~]# systemctl enable mysqld
[root@localhost ~]# systemctl restart mysqld

Default configuration file path:
Configuration file: /etc/my.cnf
Log file: /var/log/mysqld.log
Service startup script: /usr/lib/systemd/system/mysqld.service
socket file: /var/run/mysqld/
[root@localhost ~]# systemctl status firewalld
[root@localhost ~]# firewall-cmd –zone=public –add-port=80/tcp –permanent
[root@localhost ~]# firewall-cmd –zone=public –add-port=443/tcp –permanent
[root@localhost ~]# firewall-cmd –zone=public –add-port=3306/tcp –permanent
[root@localhost ~]# firewall-cmd –list-port
[root@localhost ~]# systemctl restart firewalld
Command meaning:
–zone #Scope
–add-port=80/tcp #Add port, the format is: port/communication protocol
–permanent #Permanently effective, without this parameter, it will fail after restarting
Set the boot to start:
[root@localhost ~]# systemctl enable nginx
Configure PHP support
Add in server { }:

location / {
#Define the name of the home page index file
index index.php index.html index.htm;

# All PHP script requests are forwarded to FastCGI for processing. Use FastCGI default configuration.
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root $fastcgi_script_name;
include fastcgi_params;
[root@localhost ~]# systemctl start nginx
[root@localhost ~]# systemctl enable php-fpm
[root@localhost ~]# systemctl start php-fpm
Create a php file under the /usr/share/nginx/html file and output phpinfo information
Visit http://intranet IP address/phpinfo.php with the browser, if you see PHP information, it means the installation is successful
A) Modify the configuration of php.ini
vim /etc/php.ini
cgi.fix_pathinfo=1 #Remove the comment and enable the pathinfo pseudo-static function of PHP.
max_execution_time = 0 #The maximum time the script runs, the default is 30 seconds
max_input_time = 300 #The time the script can consume, the default is 60 seconds
memory_limit = 256M #The script runs the maximum memory consumption, change the value according to your needs, the default is 128M
post_max_size = 100M #The maximum data submitted by a single submission, this item does not limit the size of a single uploaded file, but limits the submission data of the entire form. The scope of restriction includes all content submitted by the form. For example: when posting, the post title, content, attachments, etc. 8M by default
upload_max_filesize = 10M #The maximum allowed size of uploaded files, the default is 2M
Modify the configuration of php-fpm
vim /etc/php-fpm.d/www.conf
Find the following two lines and uncomment them
listen.owner = nobody = nobody
Find the following two lines and change their apache to nginx
user = apache -> user = nginx
group = apache -> group = nginx
install phpmyadmin
mv phpMyAdmin-4.4.12-all-languages /usr/share/nginx/html/phpmyadmin
chown -R nginx.nginx /var/lib/php/session
403 Forbidden solution
When visiting, nginx will search for files in the root directory in the order of index.php index.html index.htm. If none of these three files exists, nginx will return 403 Forbidden. So you can move the files under your /usr/share/nginx/html/ directory to /var/www/html/, or create index.php index.html index under the /var/www/html/ directory .htm

How to turn off SELinux in Linux
1. Temporary shutdown: Enter the command setenforce 0, and it will be turned on after restarting the system.
2. Permanent shutdown: Enter the command vi /etc/selinux/config, change SELINUX=enforcing to SELINUX=disabled, then save and exit.
CentOS 7 firewall-cmd command not found solution,
Install firewall
[root@localhost ~]# yum install firewalld

Basic usage of firewalld
Start: systemctl start firewalld
Shut down: systemctl stop firewalld
View status: systemctl status firewalld
Boot disabled: systemctl disable firewalld
Boot enable: systemctl enable firewalld
View open ports: firewall-cmd –list-ports
Add port: firewall-cmd –add-port=8080/tcp –permanent (-permanent takes effect permanently, and will fail after restarting without this parameter)
Reload without interrupting service: firewall-cmd –reload
Original articles are prohibited from reprinting


Leave A Comment?