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

[root@localhost ~]# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
[root@localhost ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
[root@localhost ~]# rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
[root@localhost ~]# yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm #used to install php7.4
===============================
[root@localhost ~]# yum -y install nginx
[root@localhost ~]# rpm -import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
[root@localhost ~]# yum -y install mysql-community-server
[root@localhost ~]# yum -y install yum-utils
[root@localhost ~]# yum-config-manager –disable ‘remi-php*’
[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
or
[root@localhost ~]# yum install -y php74 php74-php-devel php74-php-fpm php74-php-mbstring php74-php-memcache php74-php-memcached php74-php-redis php74-php-mysqlnd php74-php-pdo php74-php-bcmath php74-php-xml php74-php-gd php74-php-gmp php74-php-igbinary php74-php-imagick php74-php-mcrypt php74-php-pdo_mysql php74-php-posix php74-php-simplexml php74-php-opcache php74-php-xsl php74-php-xmlwriter php74-php-xmlreader php74-php-swoole php74-php-zip php74-php-phalcon php74-php-yaml php74-php-yar php74-php-yaf php74-php-uuid
$ php74 -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!’;
or
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/mysqld.pid
=================================
[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.
location~.php${
fastcgi_pass 127.0.0.1:9000;
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
test
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
==================================
configuration
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
listen.group = nobody
Find the following two lines and change their apache to nginx
user = apache -> user = nginx
group = apache -> group = nginx
======================================
install phpmyadmin
wget https://files.phpmyadmin.net/phpMyAdmin/4.4.12/phpMyAdmin-4.4.12-all-languages.zip
https://files.phpmyadmin.net/phpMyAdmin/5.2.1/phpMyAdmin-5.2.1-all-languages.zip //fit php74
unzip phpMyAdmin-4.4.12-all-languages.zip
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

Tagged: