Php-fpm返回“未找到页面”;应所有要求…已检查权限


php-fpm returning "page not found" on all requests ... permissions already checked

所以我要开始说我是一个很新的web服务器,这是我第一次配置。也就是说,web服务器已经启动并运行,我可以向它添加站点和文件。但是,我现在无法得到任何。php文件工作。

我目前在FreeBSD上运行nginx,并安装了php-fpm。我知道nginx正确使用php-fpm,但对于任何php文件,我尝试查看所有我得到的是"文件未找到"。我知道这是来自php-fpm,因为对于任何实际上不存在的文件,nginx会给我一个不同的"文件未找到"页面。

我已经看过几个关于这个问题的谷歌页面,最常见的解决方案是它是不正确的权限在php文件。在这一点上,我不能排除太多的可能性,但我试过改变文件和文件夹的权限,包括打开它们的所有内容,但没有成功。

这是我的nginx.conf文件,希望它能有所帮助。

user  www www;
worker_processes  4;
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
#pid        logs/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include         mime.types;
    index           index.html index.htm index.php
    default_type    application/octet-stream;
    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';
    #access_log     logs/access.log main;  ## Default: off
    sendfile        on;
    tcp_nopush      on;
    ###custom changes
    server_tokens           off;
    client_max_body_size    200M;
    client_body_buffer_size 1M;
    port_in_redirect        off;
    ###
    keepalive_timeout  15;  ## Default: 0
    gzip  on;
    ### More custom changes
    gzip_http_version 1.1;
    gzip_vary on;
    gzip_comp_level 6;
    gzip_proxied any;
    gzip_types text/plain text/css application/json application/x-javascript application/xml application/xml+rss text/javascript;
    gzip_buffers 16 8k;
    gzip_disable "MSIE [1-6].(?!.*SV1)";
    ###

    server { # simple reverse-proxy
        listen       80;
        server_name  localhost;
        #access_log   logs/mySite1.access.log;
        root /usr/local/www/mySite.com;
        location / {
            try_files $uri $uri/ /index.php;
        }
        # this prevents hidden files (beginning with a period) from being served
        location ~ /'.          { access_log off; log_not_found off; deny all; }
        #error_page  404              /404.html;
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ '.php$ {
            fastcgi_pass   127.0.0.1:9000;      
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi_params;
        }
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/local/www/nginx-dist;
        }
    }
}

如果有人对这里发生的事情有任何想法,我将不胜感激。

这可能对您有所帮助。我使用FPM的套接字,所以只是改变使用IP,但这里是我的工作配置:

example.com.conf

server {
    listen      192.168.1.1:80;
    server_name example.com;
    charset utf-8;
    access_log /vhosts/example.com/logs/access_log main;
    error_log  /vhosts/example.com/logs/error_log;
    index index.php;
    root  /vhosts/example.com/public;
    location / {
        try_files $uri $uri/ /index.php;
    }
    location ~ '.php$ {
        fastcgi_pass  unix:/usr/local/etc/php-fpm/nginx.sock;
        include       fastcgi.conf;
    }
    location ~ '.htaccess {
        deny all;
    }
}

fastcgi.conf

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;
fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  HTTPS              $https if_not_empty;
fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;
fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;

我认为您的文件系统上实际上没有目录/scripts。你可能指的是$document_root/scripts。如果你有一个目录/scripts,然后张贴php-fpm日志与SCRIPT_FILENAME日志。我认为它是默认记录的,但如果没有,语法在配置文件中解释得很好。