我正在撞墙试图让nginx运行并运行php5-fpm。我觉得这是我忽略的一个小细节,所以我休息了几天后又回来了。今晚又乱了几个小时无济于事。
无论如何,问题在于:我已经启动并运行了nginx。它似乎正在正确地提供网页。例如,http://www.shidenadvanced.com的基础网站就可以了。但是,位于http://www.shidenadvanced.com/test.php的我的php测试又回来了。以前它会以502 Bad Gateway的形式回归。
通过我的研究,我明白这意味着它无法通过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;
}
}
除此之外,我已经完成了大部分设置。不完全确定发生了什么。任何人都能解释一下吗?
答案 0 :(得分:2)
试试这个。我对你处理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;
}
}
答案 1 :(得分:2)
我个人更喜欢套接字解决方案:
fastcgi_pass unix:/path/tp/myfirst.socket;
而不是
fastcgi_pass 127.0.0.1:9000;
但你也需要主机的fpm配置:
[hak-rentrisch_de]
listen = /path/tp/myfirst.socket
listen.owner = hostuser
listen.group = hostgroup
listen.mode = 0666
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
user = hostuser
group = hostgroup
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.max_requests = 500
php_admin_value[include_path] = .:/var/www/libs
[...]
亲切的问候