Nginx Series-2. Configure LNMP (Linux, Nginx, MySQL, PHP) schema directory-Nginx series
Nginx Series -1.linux Installation Nginx
Nginx Series-2. Configuring the Lnmp (Linux, Nginx, MySQL, PHP) architecture
Nginx Series-3. Configuring Nginx Virtual Host
Nginx Series -4.nginx log configuration and log cutting
Nginx Series-5. Configure the Nginx anti-theft chain
Nginx Series-6. Configuring Nginx HTTPS
Nginx Series-7. Configuring Nginx using UWSGI support web.py framework
Nginx Series-8. Configuration nginx+apache for dynamic and static separation
Nginx Series-9. Configuring NFS for static and dynamic separation of Nginx
Nginx Series-10. Using Nginx to build forward proxy service
Nginx Series-11. Configuring Nginx Reverse proxy and load balancing
Experimental Environment
A minimized CentOS 7.3 virtual machine
First, install the package
yum install -y epel-*yum install -y nginx mariadb-server php php-fpm php-mysql php-pdo php-pdo_dblib php-json php-devel php-gd php-pear php-xml php-pecl-zip wget vim
Second, the configuration Nginx support PHP
nginx
the established home directory
mkdir /var/wwwrootcd /var/wwwrootecho -e hello_world >> index.htmlecho -e "<?php phpinfo(); ?>" >> info.php
Editing a nginx
configuration file
vim /etc/nginx/nginx.conf
modifying nginx
home directories and indexes
3.1. http
server
Change the value below root
to /var/wwwroot
3.2. Under http
server
add
index index.php index.html index.htm
Under below http
server
, add the following:
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;}
Start nginx
and php-fpm
systemctl start nginx php-fpm
Shutting down the firewall
setenforce 0systemctl stop firewalldsystemctl disable firewalld
- The host accesses Nginx
Access http://[centos_ip]/info.php
Third, configure MySQL
StartMySQL
systemctl start mariadb
Enter the following command to configureMySQL
mysql_secure_installation
Tips Enter current password for root (enter for none):
Tap Enter
Tips Set root password? [Y/n]
Press Y
, then set the password
Tips Remove anonymous users?
Meaning for是否删除匿名用户
Tips Disallow root login remotely?
Meaning for远程禁止root登录吗?
Tips Remove test database and access to it?
Meaning for删除测试数据库吗?
Tips Reload privilege tables now?
Meaning for现在重新加载特权表吗?
- Log in to MySQL database
mysql -uroot -p
Iv. Download the wordpress test LNMP
Download WordPress
cd /var/wwwrootrm -rf index.htmlrm -rf info.phpwget https://cn.wordpress.org/wordpress-4.9.4-zh_CN.tar.gztar -zxvf wordpress-4.9.4-zh_CN.tar.gzcp -rf /var/wwwroot/wordpress/* /var/wwwrootcd /var/wwwrootrm -rf wordpresschmod -R 777 *
Log in to MySQL to create a database
mysql -uroot -p
CREATE DATABASE wordpress;
- Access Nginx Server on host
Access http://[centos_ip]/
Follow the prompts to install
Nginx Series-2. Configuring the Lnmp (Linux, Nginx, MySQL, PHP) architecture