nginx配置文件:
server { listen 80; server_name localhost; access_log /var/log/nginx/log/host.access.log main; root /usr/share/nginx/html; #原本這個設置是在下面localtion里面的 location / { index index.php index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } location ~* \.php$ { fastcgi_index index.php; fastcgi_pass 127.0.0.1:9000; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; } }
php-fpm配置文件(注意:可能有些php版本不是這個文件,但只要意思到位即可):
vi /etc/php-fpm.d/www.conf
修改這兩個地方為nginx用戶

最后測試php頁面:
<?php phpinfo(); ?>
