0
votes

Just came over to the Arch side of things. I am having a lot of trouble getting my local LEMP stack to work to work on Antergos. Currently the server block local page is returning a 403 error.

/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;
        }

}

And the last entry in the error log:

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

And an ls -la of the www folder reveals:

[l@l project]$ ls -la total 12 drwxr-xr-x 3 l users 4096 Jun 28 10:14 . drwxr-xr-x 4 l users 4096 Jun 28 10:13 .. drwxrwxrwx 4 l users 4096

Inside the www folder there is a test folder, also 'l users' and inside of the test folder is index.php also belong to l and users respectively.

EDIT: Question to be considered closed. Moved to Ubuntu 16.04 Gnome.

2

2 Answers

0
votes

Try moving your www directory outside of /home. For example, you could move it to /srv/www and change the owner of the directory to the html user and group:

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

Be sure to update your nginx.conf accordingly. Hope it helps!

0
votes

I see the "question is considered closed" line, but I'll put an answer for the sake of anyone else who might stumble over this.

If you're not a fan of changing the owner/group for various reasons, you can get away by changing permissions. You need read permission for files (assuming you aren't changing them). In order to access folders, you need both read and execute.

Therefore:

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

Note that this probably isn't a good idea for a live site, but should cut it just fine for testing purposes.