404错误与任何PHP文件,使用nginx的(404 error with any php file

2019-09-28 22:35发布

我意识到这个问题已经被问了无数次,但尽管我所有的尝试都到位了各种解决方案徇我还没有解决我的问题:

不管我做什么,我的网站上的任何PHP文件给我一个404错误。 HTML文件很好地工作,但是。

我的nginx.conf:

user www-data;
worker_processes auto;
pid /run/nginx.pid;

events {
        worker_connections 768;
        # multi_accept on;
}

http {
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POOD$
        ssl_prefer_server_ciphers on;

        access_log /home/****/websites/logs/access.log;
        error_log /home/****/websites/logs/error.log;

        include v-hosts/*.conf;
        #### prevent processing requests with undefined server names
        server  {
                listen 80;
                server_name '';
                return 444;
        }


}

我/etc/nginx/v-hosts/website.com.conf

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /home/*****/websites/website.com/root;
    index index.php index.html index.htm;

    server_name website.com www.website.com;

    location / {
        try_files $uri $uri/ =404;
        root /home/****/websites/website.com/root;
        index index.php index.html index.html;
    }

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root /home/****/websites/website.com/root;
    }

    location ~ \.php$ {
        root /home/****/websites/website.com/root;
        try_files $uri =404;

        fastcgi_pass unix:/run/php7.0-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        }
}
  • 我已经设置cgi.fix_pathinfo=0php.ini
  • 我有一个index.php文件 ,以及在/home/****/websites/website.com/root的info.php的

谢谢

Answer 1:

我已经成功地固定我的问题! 在/home/****/websites/logs/error.log访问错误日志之后,我意识到自己的路径fastcgi_pass unix:/run/php7.0-fpm.sock; 错了。 我已经改变了它fastcgi_pass unix:/run/php/php7.0-fpm.sock; 并在页面现在显示正确!

`



文章来源: 404 error with any php file, using nginx
标签: php nginx