[英]Nginx with PHP5-FPM — .php files giving blank screens
我正在撞墙试图让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;
}
}
除此之外,我已经完成了大部分设置。 不完全确定发生了什么。 任何人都能解释一下吗?
试试这个。 我对你处理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;
}
}
我个人更喜欢套接字解决方案:
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
[...]
亲切的问候
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.