Nginx + php-fpm给出找不到文件

时间:2014-12-12 17:54:56

标签: nginx php

我在nginx上遇到File not found错误,我一直试图解决这个问题几个小时。配置看起来类似于我在其他网站上使用的但我不知道为什么它没有' t work.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.Thanks帮助我

1 个答案:

答案 0 :(得分:0)

首先

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

secand add

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