服务器 - nginx php配置

原创
2016-06-06 20:30:21 728浏览

server {
listen 8080;
server_name xxx.me;

root /www/;
index index.html index.htm index.php;

location / {
    try_files $uri $uri/ /index.php;
}

location ~ \.php$ {
    try_files $uri =404;

    include fastcgi.conf;
    fastcgi_pass 127.0.0.1:9000;
}

}
我已经安装好php和nginx了。在根目录下建了个www文件夹。按照这个配置,我去访问xxx.me
直接返回Welcome to nginx!。然后我在www文件夹下面建了个index.html文件,也是提示Welcome to nginx!这个信息,而我又建了个index.php,返回404,是不是我的哪里配置错了。一直返回nginx的信息,求大神告知,小菜鸟一个。

回复内容:

server {
listen 8080;
server_name xxx.me;

root /www/;
index index.html index.htm index.php;

location / {
    try_files $uri $uri/ /index.php;
}

location ~ \.php$ {
    try_files $uri =404;

    include fastcgi.conf;
    fastcgi_pass 127.0.0.1:9000;
}

}
我已经安装好php和nginx了。在根目录下建了个www文件夹。按照这个配置,我去访问xxx.me
直接返回Welcome to nginx!。然后我在www文件夹下面建了个index.html文件,也是提示Welcome to nginx!这个信息,而我又建了个index.php,返回404,是不是我的哪里配置错了。一直返回nginx的信息,求大神告知,小菜鸟一个。

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;
    }

把您的这部分按照这里修改一下,这是nginx安装好以后的默认配置。
centos + nginx + php-fpm +mysql的简单配置

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。