实验环境:CentOS7
服务器172.16.252.142做Nginx代理服务器:
[root@conf.d localhost]#iptables -F [root@conf.d localhost]#setenforce 0 [root@conf.d localhost]#yum -y install nginx [root@conf.d localhost]#cd /etc/nginx/conf.d/ [root@conf.d localhost]#vim default.conf #静态资源和动态资源全部用一台服务器172.16.254.47,用不同的端口; server { listen 80; server_name www.mylinux.io; location ~* \.(html|js|css|jpg|jpeg|png|gif)$ { #location / { proxy_pass http://172.16.254.47:80; } location ~* \.php$ { fastcgi_pass 172.16.254.47:9000; fastcgi_index index.php; include fastcgi_params; #向后端php-fpm服务器传递脚本的方式:是在fastcgi_param文件中,将变量SCRIPT_NAME向后传递,/data/apps是php-fpm的document路径 fastcgi_param SCRIPT_FILENAME /var/www/html/wordpress$fastcgi_script_name; } } [root@conf.d localhost]#nginx -t [root@conf.d localhost]#nginx -s reload
RS:172.16.254.47
[root@html localhost]#yum -y install mariadb-server php-mysql [root@html localhost]#chown -R nginx:nginx wordpress/ [root@html localhost]#vim /etc/php-fpm.d/www.conf listen = 172.16.254.47:9000 #监听本地地址 listen.allowed_clients = 172.16.252.142 #Nginx代理服务器的地址 [root@html localhost]#mysql -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 286 Server version: 5.5.52-MariaDB MariaDB Server Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> GRANT ALL ON wp.* TO wp@'172.16.254.47' IDENTIFIED BY '123456'; MariaDB [(none)]> CREATE DATABASE wp; MariaDB [(none)]> FLUSH PRIVILEGES;