簡體   English   中英

使用nginx的任何php文件出現404錯誤

[英]404 error with any php file, using nginx

我意識到這個問題已經被問過無數次了,盡管我竭盡全力提出各種解決方案,但許多人都建議我尚未解決我的問題:

無論我做什么,我網站上的任何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)(/.+)$;
        }
}
  • 我已經在php.ini中設置了cgi.fix_pathinfo=0
  • 我在/home/****/websites/website.com/root中有一個index.php以及一個info.php

謝謝

我已經成功解決了我的問題! 訪問/home/****/websites/logs/error.log中的錯誤日志后,我意識到我的路徑fastcgi_pass unix:/run/php7.0-fpm.sock; 錯了。 我已經將其更改為fastcgi_pass unix:/run/php/php7.0-fpm.sock; 現在頁面可以正確顯示!

`

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM