Home >Backend Development >PHP Tutorial >服务器 - nginx php配置

服务器 - nginx php配置

WBOY
WBOYOriginal
2016-06-06 20:30:211019browse

server {
listen 8080;
server_name xxx.me;

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

}
我已经安装好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;

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

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

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

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn