File Not Found when running PHP with Nginx

后端 未结 15 1947
后悔当初
后悔当初 2020-12-04 13:59

Recently I installed the latest version of Nginx and looks like I\'m having hard time running PHP with it.

Here is the configuration file I\'m using for the domain:<

15条回答
  •  南方客
    南方客 (楼主)
    2020-12-04 14:39

    I had the "file not found" problem, so I moved the "root" definition up into the "server" bracket to provide a default value for all the locations. You can always override this by giving any location it's own root.

    server {
        root /usr/share/nginx/www;
        location / {
                #root /usr/share/nginx/www;
        }
    
        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                include fastcgi_params;
        }
    }
    

    Alternatively, I could have defined root in both my locations.

提交回复
热议问题