访问index.html正常,访问index.php找不到文件
php-fpm正常启动
[root@nginx sbin]# ps -ef |grep php-fpm
root 95107 1 0 15:55 ? 00:00:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
www 95108 95107 0 15:55 ? 00:00:00 php-fpm: pool www
www 95109 95107 0 15:55 ? 00:00:00 php-fpm: pool www
root 95239 24085 0 16:12 pts/0 00:00:00 grep --color=auto php-fpm
nginx配置文件
[root@nginx sbin]# cat /usr/local/nginx/conf/nginx.conf
server {
listen 80;
server_name 192.168.139.102;
#charset koi8-r;
#access_log logs/host.access.log main;
#root /usr/local/nginx/html/wordpress;
root html;
location / {
#root html;
#root /usr/local/nginx/html/wordpress;
index index.html index.htm readme.html;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
# root /usr/local/nginx/html/wordpress;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /document_root$fastcgi_script_name;
include fastcgi_params;
}
}
测试用代码
[root@nginx sbin]# cat /usr/local/nginx/html/index.php
<?php
phpinfo();
?>
不知道什么原因
你的文件读取都没有启用,最关键,php的根目录又没指定,人家怎么去找呢?
例如一个常规设置如下:
server {
#监听端口
listen 80;
server_name xxxx.com;
index index.html index.htm index.php;
。。。。。
location ~ \.php$ {
root /usr/local/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
在很多位置,都没有看到你启用 index.php 这个,又没看到找哪里目录。