Nginx和php-fpm部署到不同的服务器

1.编辑php配置文件
vim /usr/local/php-7.1.3/etc/php-fpm.d/www.conf
[global]pid = /usr/local/php-7.1.3/var/run/php-fpm.piderror_log = /usr/local/php-7.1.3/var/log/php-fpm.log[php]listen = 0.0.0.0:9002listen.allowed_clients = 192.168.1.251 #Nginx服务器的ip地址user = phpgroup = phppm = dynamicpm.max_children = 50pm.start_servers = 20pm.min_spare_servers = 5pm.max_spare_servers = 35pm.max_requests = 500rlimit_files = 1024slowlog = /tmp/phpslow.logrequest_slowlog_timeout = 12、编辑Nginx的配置文件
【Nginx和php-fpm部署到不同的服务器】server { listen 80; server_tokens off; server_name ServerName; location ~ .php$ { root /opt/html; #这是php-fpm服务器上的地址,并不是Nginx的本地地址哦 。fastcgi_pass 192.168.1.250:9002; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }3、启动php-fpm和Nginx的服务即可访问了,不过要在ServerName后面加上index.php

Nginx和php-fpm部署到不同的服务器

文章插图




    推荐阅读