【问题标题】:Nginx + php-fpm gives file not foundNginx + php-fpm 给出文件未找到
【发布时间】:2017-07-08 19:52:53
【问题描述】:

我在使用 nginx 时遇到 File not found 错误,我已经尝试修复了几个小时。配置看起来类似于我在其他网站上使用的配置,但我不知道为什么它不起作用。html 文件有效好想。

顺便说一句,我看了这个post,但仍然找不到我的问题。

server {
    listen 80;
    server_name servergreek.com   167.88.125.157;
    return 301 http://www.servergreek.com$request_uri;
}
server {
    listen      80 default_server; 
    server_name  www.servergreek.com;
    access_log   /home/servergreek.com/public_html/logs/access_log main;
    error_log     /home/servergreek.com/public_html/logs/error_log crit; 
    root /home/servergreek.com/public_html/www;
    index index.php index.html index.htm;

    #Serve static content directly
    location ~* \.(jpg|jpeg|gif|css|png|js|ico|html|woff)$ {
    access_log off;
    expires max;
    }

    location ~ ^/tmp/(.*)$ {
    deny all;
    }



    # Zend Opcache rules
        #location  /opcache/ {
            # root /home/servergreek.com/public_html/www;
            # index index.php index.html index.htm;
            # auth_basic            "Restricted Area (Secured by Khavish)";
            # auth_basic_user_file  /var/www/servergreek.com/private/htpasswd;
        #}

    # Only requests to our Host are allowed
    if ($host  !~ ^(servergreek.com|www.servergreek.com)$ ) {
         return 444;
      }

     location ~* \.php$ {
        root /home/servergreek.com/public_html/www;
        fastcgi_pass   unix:/tmp/php5-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include        fastcgi_params;
        fastcgi_connect_timeout 60;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;
        fastcgi_buffer_size 128k;
        fastcgi_buffers 256 16k;
        fastcgi_busy_buffers_size 256k;

    } 

    #location ~ /\.ht {
     #  deny  all;
    #}


      }

index.php 位置是 /home/servergreek.com/public_html/www/index.php。感谢您帮助我

【问题讨论】:

  • 配置看起来不错。有几个 cmets 但并不重要。不工作 www.servergreek.com/ 或 www.servergreek.com/index.php 呢? /tmp/php5-fpm.sock 是否存在? Nginx 重启了吗?
  • @Terra servergreek.com/ 和 servergreek.com/index.php 显示相同的错误并且 /tmp/php5-fpm.sock 存在
  • “找不到文件”的外观如何? nginx签名的标准404错误?你能在你的 access_log 中看到这个请求吗?
  • @Terra 只看到“找不到文件”文本,没有任何 nginx 签名
  • 好的,这是 PHP 消息。检查 fastcgi_params - 可能在此文件中重写了 SCRIPT_FILENAME。

标签: nginx php


【解决方案1】:

第一

chmod 0755  /home/servergreek.com/
chmod 0755  /home/servergreek.com/public_html/
chmod 0755  /home/servergreek.com/public_html/www

秒加

location / {
            root   /home/servergreek.com/public_html/www/;
            index  index.html index.htm index.php ;
    }

【讨论】:

    猜你喜欢
    • 2023-03-07
    • 2014-08-04
    • 1970-01-01
    • 1970-01-01
    • 2015-11-17
    • 2021-04-02
    • 2014-08-17
    • 2016-12-02
    • 1970-01-01
    相关资源
    最近更新 更多