首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Antergos Linux - LEMP堆栈- Nginx 403

Antergos Linux - LEMP堆栈- Nginx 403
EN

Stack Overflow用户
提问于 2016-06-28 19:41:26
回答 1查看 230关注 0票数 0

刚走到拱门那边。我有很多麻烦,让我的本地LEMP堆栈工作的Antergos。当前,服务器块本地页正在返回403错误。

/etc/nginx/nginx.conf:

代码语言:javascript
复制
#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/站点-现有/项目。

代码语言:javascript
复制
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 28652#28652:*1 open() "/home/l/install/project/www /test”失败(13:拒绝许可),客户端: 127.0.0.1,服务器: project.local,请求:"GET /test HTTP/1.1",主机:"project.local“

www文件夹的ls -la显示:

l@l项目$ ls -la共计12 drwxr-xr-x3 l用户4096 6月28日10:14。drwxr xr-x4 l用户4096 6月28日10:13。drwxrwxrwx 4 l用户4096

在www文件夹中有一个测试文件夹,也有'l用户‘,在测试文件夹的内部是index.php也分别属于l和users。

编辑:被视为已结束的问题。搬到Ubuntu 16.04 Gnome。

EN

回答 1

Stack Overflow用户

发布于 2016-06-30 14:41:40

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

代码语言:javascript
复制
sudo mv /home/l/www /srv
sudo chown -R html:html /srv/www

确保相应地更新您的nginx.conf。希望能帮上忙!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38084963

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档