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.pid error_log = /usr/local/php-7.1.3/var/log/php-fpm.log [php] listen = 0.0.0.0:9002 listen.allowed_clients = 192.168.1.251 #Nginx服务器的ip地址 user = php group = php pm = dynamic pm.max_children = 50 pm.start_servers = 20 pm.min_spare_servers = 5 pm.max_spare_servers = 35 pm.max_requests = 500 rlimit_files = 1024 slowlog = /tmp/phpslow.log request_slowlog_timeout = 1
2、编辑Nginx的配置文件
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