纯粹笔记整理,非原创
关键配置
1、nginx.conf:
upstream phpCluster{ server web-php1.life.com:9000; server web-php2.life.com:9000; } server { listen 8080; server_name nginx.life.com; index index.php index.html index.htm; root /home/nginx/html; charset utf-8; location ~ .*\.(php|php5) { fastcgi_pass phpCluster; fastcgi_index index.php; include fastcgi.conf; set $path_info ""; set $real_script_name $fastcgi_script_name; if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") { set $real_script_name $1; set $path_info $2; } fastcgi_param SCRIPT_FILENAME $document_root$real_script_name; fastcgi_param SCRIPT_NAME $real_script_name; fastcgi_param PATH_INFO $path_info; } }
2、php-fpm.conf
listen = 0.0.0.0:9000 listen.allowed_clients = 10.0.2.11,10.0.2.12,127.0.0.1 request_terminate_timeout = 60s
3、网站根目录
nginx服务器与php服务器的根目录要一致,并且需要赋予相应的权限
nginx:root /home/nginx/html;
php:
[php@web-php1 ~]$ ll total 12 drwxrwxr-x 2 php php 4096 Dec 30 16:04 crontab drwxrwxr-x 3 php php 4096 Dec 30 16:04 data lrwxrwxrwx 1 php php 17 Dec 30 16:07 html -> /home/nginx/html/ drwxr-xr-x 9 php php 4096 Dec 30 16:01 php