2016-06-28 64 views
0

刚刚来到事物的拱侧。让我的本地LEMP堆栈工作在Antergos上,我遇到了很多麻烦。目前服务器块本地页面正在返回403错误。Antergos Linux - LEMP堆栈 - Nginx 403

/etc/nginx/nginx.conf:

#user html; 
worker_processes 1; 

#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; 
    include  sites-enabled/*; 
    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; 

    sendfile  on; 
    #tcp_nopush  on; 

    #keepalive_timeout 0; 
    keepalive_timeout 65; 

    #gzip on; 

    server { 
     listen  80; 
     server_name localhost; 

     #charset koi8-r; 

     #access_log logs/host.access.log main; 

     location/{ 
      root /usr/share/nginx/html; 
      index index.html index.htm; 
     } 

     #error_page 404    /404.html; 

     # redirect server error pages to the static page /50x.html 
     # 
     error_page 500 502 503 504 /50x.html; 
     location = /50x.html { 
      root /usr/share/nginx/html; 
     } 

     # proxy the PHP scripts to Apache listening on 127.0.0.1:80 
     # 
     #location ~ \.php$ { 
     # proxy_pass http://127.0.0.1; 
     #} 

     # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 
     # 
     #location ~ \.php$ { 
     # root   html; 
     # fastcgi_pass 127.0.0.1:9000; 
     # fastcgi_index index.php; 
     # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; 
     # include  fastcgi_params; 
     #} 

     # deny access to .htaccess files, if Apache's document root 
     # concurs with nginx's one 
     # 
     #location ~ /\.ht { 
     # deny all; 
     #} 
    } 


    # another virtual host using mix of IP-, name-, and port-based configuration 
    # 
    #server { 
    # listen  8000; 
    # listen  somename:8080; 
    # server_name somename alias another.alias; 

    # location/{ 
    #  root html; 
    #  index index.html index.htm; 
    # } 
    #} 


    # HTTPS server 
    # 
    #server { 
    # listen  443 ssl; 
    # server_name localhost; 

    # ssl_certificate  cert.pem; 
    # ssl_certificate_key cert.key; 

    # ssl_session_cache shared:SSL:1m; 
    # ssl_session_timeout 5m; 

    # ssl_ciphers HIGH:!aNULL:!MD5; 
    # ssl_prefer_server_ciphers on; 

    # location/{ 
    #  root html; 
    #  index index.html index.htm; 
    # } 
    #} 

} 

/etc/nginx/sites-available/projects.local

server { 
    listen 80; 
    #listen [::]:80; 

    server_name project.local www.project.local; 

    root /home/l/install/project/www; 

    access_log /home/l/install/project/www/log/access.log; 
    error_log /home/l/install/project/www/log/error.log; 

     location/{ 
      index index.html index.htm index.php; 
     } 

     location ~ \.php$ { 
       fastcgi_split_path_info ^(.+\.php)(/.+)$; 
       fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; 
       fastcgi_index index.php; 
       include fastcgi_params; 
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
     } 

} 

,并在错误日志中的最后一项:

“GET /test/index.html HTTP/1.1”,主机:“project.local”2016/06/28 12:18:45 [error] 28652#28652:* 1 open() “/ home/l/install/project/www/test”失败(13:Permission denied), client:127.0.0.1,server:project.local,request:“GET/test HTTP/1.1”,host: project.local”

和WWW文件夹的LS -la显示:

[l在l项目] $ LS -la 共有12 drwxr-XR-×3 L个用户4096 Jun 28 10:14。 drwxr-XR-×4个用户4096年06月28 10:13 .. drwxrwxrwx4升用户4096

里面的WWW文件夹有一个测试文件夹,也“升用户”和测试文件夹内index.php也分别属于l和users。

编辑:问题被视为封闭。移到Ubuntu 16.04 Gnome。

回答

0

尝试移动您的www目录以外的/home。例如,你可以将它移动到/srv/www和目录的所有者更改为html用户和组:

sudo mv /home/l/www /srv 
sudo chown -R html:html /srv/www 

务必将nginx.conf相应的更新。希望能帮助到你!

+0

我以前曾尝试使用服务器块(虚拟主机)和chown命令。目前我转回到Ubuntu Gnome。不管怎样,谢谢你!! – dottel

0

我看到“问题被认为是封闭的”路线,但是我会为其他任何可能会偶然发现的人提供答案。

如果您不是因为各种原因更改所有者/群组的粉丝,可以通过更改权限离开。您需要文件的读取权限(假设您没有更改它们)。为了访问文件夹,您需要读取和执行。

因此:

chmod -R o+rx /home/1/www 

注意,这可能不是一个活的网站好主意,但应该削减它就好了用于测试目的。

+0

谢谢。页面会频繁更改,如每分钟几次。这是一个开发环境。 – dottel