下面是ngnix配置虚拟主机的配置文件内容(其中root目录已经设置上述rwx权限):
server {
listen 80;
index index.php index.html index.htm;
root /home/deploy/apps/xiaopo.me/current/public;
server_name xiaopo.me www.xiaopo.me;
location / {
try_files $uri $uri/ /index.html;
}
location ~ \.php$ {
try_files $uri = 404;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
}
}
随后在root指定的/home/deploy/apps/xiaopo.me/current/public目录下新建index.php,内容为echo phpinfo();,访问网址一片空白。新建index.html却是可以访问,那么说明php-fpm没有解析php文件,是没有传过去吗?
我用了一些在网上的排查手段,依然无果,遂来论坛求助前辈,谢谢。
****************************************************************************************************************************************************************************************************************************************************************************
排查1:在修改配置文件之后,多次从网上参考配置文件写法,改写文件后多次使用sudo service nginx restart和sudo service php-fpm restart重启nginx、php-fpm也没有效果。
排查2:排除版本问题,php-fpm安装的是php70w-fpm包。
排查3:首先查看php-fpm的监听端口9000是否处于listen状态,发现是监听状态的:
运行sudo netstat -ntpl
结果:
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 6946/php-fpm
排查4:查看相关进程如下
ps -aux
结果:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.1 2904 884 ? Ss Nov01 0:00 init
root 2 0.0 0.0 0 0 ? S Nov01 0:00 [kthreadd/378775]
root 3 0.0 0.0 0 0 ? S Nov01 0:00 [khelper/378775]
root 169 0.0 0.0 2472 268 ? S<s Nov01 0:00 /sbin/udevd -d
root 595 0.0 0.0 5400 368 ? S<s Nov01 0:00 /root/vpnserver/vpnserver execsvc
root 596 1.1 0.9 31384 4936 ? S<l Nov01 27:50 /root/vpnserver/vpnserver execsvc
root 619 0.0 0.1 8652 584 ? Ss Nov01 0:00 /usr/sbin/sshd
root 673 0.0 0.6 11524 3512 ? Ss Nov01 0:11 /usr/bin/python /usr/bin/ssserver -c /etc/shad
root 696 0.0 0.2 11128 1460 ? Ss Nov01 0:01 /usr/bin/python /usr/bin/ssserver -c /etc/shad
root 718 0.0 0.3 11468 1980 ? Ss Nov01 0:02 /usr/bin/python /usr/bin/ssserver -c /etc/shad
root 6370 0.0 0.6 12144 3448 ? Ss Nov02 0:00 sshd: deploy [priv]
deploy 6372 0.0 0.2 12144 1180 ? S 00:00 0:00 sshd: deploy@pts/0
deploy 6373 0.0 0.2 3160 1524 pts/0 Ss 00:00 0:00 -bash
root 6647 0.0 0.2 3464 1408 pts/0 S 00:41 0:00 su root
root 6648 0.0 0.2 3056 1340 pts/0 S 00:41 0:00 bash
root 6811 0.0 0.1 3072 984 pts/0 S 00:46 0:00 su deploy
deploy 6812 0.0 0.2 3160 1544 pts/0 S 00:46 0:00 bash
root 6919 0.0 0.2 15740 1564 ? Ss 01:16 0:00 nginx: master process /usr/sbin/nginx -c /etc/
nginx 6921 0.0 0.4 15920 2484 ? S 01:16 0:00 nginx: worker process
root 6946 0.0 0.7 161412 3680 ? Ss 01:16 0:00 php-fpm: master process (/etc/php-fpm.conf)
deploy 6948 0.0 0.7 161608 3888 ? S 01:16 0:00 php-fpm: pool www
deploy 6949 0.0 0.7 161608 3904 ? S 01:16 0:00 php-fpm: pool www
deploy 6950 0.0 0.8 161608 4208 ? S 01:16 0:00 php-fpm: pool www
deploy 6982 0.0 0.1 2860 960 pts/0 R+ 01:42 0:00 ps -aux
排查5:测试配置文件写得是否正确
sudo /etc/init.d/nginx configtest
结果:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
总感觉还是配置文件的问题,但是不知道到底是哪儿写错了,依然不能解析php,望前辈指教。