我把头撞在墙上,试图启动Nginx并使用PHP5-fpm运行.我觉得这只是我忽略的一个小细节,所以我休息了一会儿,几天后又回到了上面.今晚又弄乱了几个小时,无济于事.
无论如何,这就是问题所在:我已经启动并运行了Nginx.它似乎可以正确提供网页.例如,基本网站http://www.shidenadvanced.com可以正常运行.但是,我位于http://www.shidenadvanced.com/test.php的PHP测试返回为空白.以前,它是作为502错误网关返回的.
通过研究,我了解到这意味着它无法正确地通过PHP-fpm进行路由.并非100%.
这是我的/ sites-available / config:
server {
server_name www.shidenadvanced.com shidenadvanced.com;
access_log /srv/sites/shidenadvanced/logs/access.log;
error_log /srv/sites/shidenadvanced/logs/error.log;
root /srv/sites/shidenadvanced/www;
index index.PHP index.html index.htm;
location / {
try_files $uri $uri/ /index.html;
}
#location ~ \.PHP${
# try_files $uri =404;
# include /etc/Nginx/fastcgi_params;
# fastcgi_pass unix:/var/run/PHP-fpm5.sock;
# fastcgi_index index.PHP;
# fastcgi_param SCRIPT_FILENAME /srv/sites/shidenadvanced/www$fastcgi_script_name;
#}
location ~ \.PHP${
try_files $uri =404;
fastcgi_split_path_info ^(.+\.PHP)(/.+)$;
fastcgi_pass unix:/var/run/PHP5-fpm.sock;
fastcgi_index index.PHP;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
除此以外,我不理会大多数设置.不能完全确定发生了什么.谁能阐明一些想法?
最佳答案
尝试这个.我对您处理fastcgi的方式做了一些更改
server {
server_name www.shidenadvanced.com shidenadvanced.com;
access_log /srv/sites/shidenadvanced/logs/access.log;
error_log /srv/sites/shidenadvanced/logs/error.log;
root /srv/sites/shidenadvanced/www;
index index.PHP index.html index.htm;
location / {
try_files $uri $uri/ /index.html;
}
# use fastcgi for all PHP files
location ~ \.PHP$
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.PHP;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}