Nginx:无法访问此站点;权限配置?

时间:2017-05-29 23:43:21

标签: nginx permissions vps

在VPS上设置nginx的过程中,我发现标题中描述的通用“无法访问网站”错误。这是/etc/nginx/sites-available/domainname.com

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

        root /var/www/domainname.com/public;
        index index.php index.html index.htm

        server_name domainname.com;
       location / {
                try_files $uri $uri/ /index.php?$query_string;
        }

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        }

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

这是/etc/nginx/sites-enabled中的sym链接。域名和VPS的IP地址都返回相同的错误。我记得几个月前有一个类似的问题,最终需要改变某些文件权限,甚至写下发生的事情,但无法找到关于此事的笔记。不过,我怀疑权限再次成为问题的一部分。

据我所知,问题可能是对nginx目录或我的php目录或运行nginx进程的用户的内容的权限。为此,这是{/ 1}}为/ etc / nginx返回的内容:

ls -la

/ etc / php的输出:

 ls -la -R /etc/nginx
/etc/nginx:
total 64
drwxr-xr-x  6 root root 4096 May 29 22:32 .
drwxr-xr-x 98 root root 4096 May 29 22:34 ..
drwxr-xr-x  2 root root 4096 Oct 27  2016 conf.d
-rw-r--r--  1 root root 1077 Apr 26  2016 fastcgi.conf
-rw-r--r--  1 root root 1007 Apr 26  2016 fastcgi_params
-rw-r--r--  1 root root 2837 Apr 26  2016 koi-utf
-rw-r--r--  1 root root 2223 Apr 26  2016 koi-win
-rw-r--r--  1 root root 3957 Apr 26  2016 mime.types
-rw-r--r--  1 root root 1462 Apr 26  2016 nginx.conf
-rw-r--r--  1 root root  180 Apr 26  2016 proxy_params
-rw-r--r--  1 root root  636 Apr 26  2016 scgi_params
drwxr-xr-x  2 root root 4096 May 29 23:25 sites-available
drwxr-xr-x  2 root root 4096 May 29 23:28 sites-enabled
drwxr-xr-x  2 root root 4096 May 29 22:32 snippets
-rw-r--r--  1 root root  664 Apr 26  2016 uwsgi_params
-rw-r--r--  1 root root 3071 Apr 26  2016 win-utf

/etc/nginx/conf.d:
total 8
drwxr-xr-x 2 root root 4096 Oct 27  2016 .
drwxr-xr-x 6 root root 4096 May 29 22:32 ..

/etc/nginx/sites-available:
total 12
drwxr-xr-x 2 root root 4096 May 29 23:25 .
drwxr-xr-x 6 root root 4096 May 29 22:32 ..
-rw-r--r-- 1 root root 2129 May 29 22:57 domainname

/etc/nginx/sites-enabled:
total 8
drwxr-xr-x 2 root root 4096 May 29 23:28 .
drwxr-xr-x 6 root root 4096 May 29 22:32 ..
lrwxrwxrwx 1 root root   34 May 29 22:32 default -> /etc/nginx/sites-available/default
lrwxrwxrwx 1 root root   40 May 29 23:28 domainname -> /etc/nginx/sites-available/domainname

/etc/nginx/snippets:
total 16
drwxr-xr-x 2 root root 4096 May 29 22:32 .
drwxr-xr-x 6 root root 4096 May 29 22:32 ..
-rw-r--r-- 1 root root  422 Apr 26  2016 fastcgi-php.conf
-rw-r--r-- 1 root root  217 Apr 26  2016 snakeoil.conf

以下是ls -la -R /etc/php /etc/php: total 12 drwxr-xr-x 3 root root 4096 May 29 22:34 . drwxr-xr-x 98 root root 4096 May 29 22:34 .. drwxr-xr-x 5 root root 4096 May 29 22:34 7.0 /etc/php/7.0: total 20 drwxr-xr-x 5 root root 4096 May 29 22:34 . drwxr-xr-x 3 root root 4096 May 29 22:34 .. drwxr-xr-x 3 root root 4096 May 29 22:34 cli drwxr-xr-x 4 root root 4096 May 29 22:40 fpm drwxr-xr-x 2 root root 4096 May 29 22:34 mods-available /etc/php/7.0/cli: total 84 drwxr-xr-x 3 root root 4096 May 29 22:34 . drwxr-xr-x 5 root root 4096 May 29 22:34 .. drwxr-xr-x 2 root root 4096 May 29 22:34 conf.d -rw-r--r-- 1 root root 70655 May 11 23:12 php.ini /etc/php/7.0/cli/conf.d: total 8 drwxr-xr-x 2 root root 4096 May 29 22:34 . drwxr-xr-x 3 root root 4096 May 29 22:34 .. lrwxrwxrwx 1 root root 39 May 29 22:34 10-opcache.ini -> /etc/php/7.0/mods-available/opcache.ini lrwxrwxrwx 1 root root 35 May 29 22:34 10-pdo.ini -> /etc/php/7.0/mods-available/pdo.ini lrwxrwxrwx 1 root root 40 May 29 22:34 20-calendar.ini -> /etc/php/7.0/mods-available/calendar.ini lrwxrwxrwx 1 root root 37 May 29 22:34 20-ctype.ini -> /etc/php/7.0/mods-available/ctype.ini lrwxrwxrwx 1 root root 36 May 29 22:34 20-exif.ini -> /etc/php/7.0/mods-available/exif.ini lrwxrwxrwx 1 root root 40 May 29 22:34 20-fileinfo.ini -> /etc/php/7.0/mods-available/fileinfo.ini lrwxrwxrwx 1 root root 35 May 29 22:34 20-ftp.ini -> /etc/php/7.0/mods-available/ftp.ini lrwxrwxrwx 1 root root 39 May 29 22:34 20-gettext.ini -> /etc/php/7.0/mods-available/gettext.ini lrwxrwxrwx 1 root root 37 May 29 22:34 20-iconv.ini -> /etc/php/7.0/mods-available/iconv.ini lrwxrwxrwx 1 root root 36 May 29 22:34 20-json.ini -> /etc/php/7.0/mods-available/json.ini lrwxrwxrwx 1 root root 40 May 29 22:34 20-mbstring.ini -> /etc/php/7.0/mods-available/mbstring.ini lrwxrwxrwx 1 root root 41 May 29 22:34 20-pdo_pgsql.ini -> /etc/php/7.0/mods-available/pdo_pgsql.ini lrwxrwxrwx 1 root root 37 May 29 22:34 20-pgsql.ini -> /etc/php/7.0/mods-available/pgsql.ini lrwxrwxrwx 1 root root 36 May 29 22:34 20-phar.ini -> /etc/php/7.0/mods-available/phar.ini lrwxrwxrwx 1 root root 37 May 29 22:34 20-posix.ini -> /etc/php/7.0/mods-available/posix.ini lrwxrwxrwx 1 root root 40 May 29 22:34 20-readline.ini -> /etc/php/7.0/mods-available/readline.ini lrwxrwxrwx 1 root root 37 May 29 22:34 20-shmop.ini -> /etc/php/7.0/mods-available/shmop.ini lrwxrwxrwx 1 root root 39 May 29 22:34 20-sockets.ini -> /etc/php/7.0/mods-available/sockets.ini lrwxrwxrwx 1 root root 39 May 29 22:34 20-sysvmsg.ini -> /etc/php/7.0/mods-available/sysvmsg.ini lrwxrwxrwx 1 root root 39 May 29 22:34 20-sysvsem.ini -> /etc/php/7.0/mods-available/sysvsem.ini lrwxrwxrwx 1 root root 39 May 29 22:34 20-sysvshm.ini -> /etc/php/7.0/mods-available/sysvshm.ini lrwxrwxrwx 1 root root 41 May 29 22:34 20-tokenizer.ini -> /etc/php/7.0/mods-available/tokenizer.ini /etc/php/7.0/fpm: total 96 drwxr-xr-x 4 root root 4096 May 29 22:40 . drwxr-xr-x 5 root root 4096 May 29 22:34 .. drwxr-xr-x 2 root root 4096 May 29 22:34 conf.d -rw-r--r-- 1 root root 4421 May 11 23:12 php-fpm.conf -rw-r--r-- 1 root root 70997 May 29 22:40 php.ini drwxr-xr-x 2 root root 4096 May 29 22:34 pool.d /etc/php/7.0/fpm/conf.d: total 8 drwxr-xr-x 2 root root 4096 May 29 22:34 . drwxr-xr-x 4 root root 4096 May 29 22:40 .. lrwxrwxrwx 1 root root 39 May 29 22:34 10-opcache.ini -> /etc/php/7.0/mods-available/opcache.ini lrwxrwxrwx 1 root root 35 May 29 22:34 10-pdo.ini -> /etc/php/7.0/mods-available/pdo.ini lrwxrwxrwx 1 root root 40 May 29 22:34 20-calendar.ini -> /etc/php/7.0/mods-available/calendar.ini lrwxrwxrwx 1 root root 37 May 29 22:34 20-ctype.ini -> /etc/php/7.0/mods-available/ctype.ini lrwxrwxrwx 1 root root 36 May 29 22:34 20-exif.ini -> /etc/php/7.0/mods-available/exif.ini lrwxrwxrwx 1 root root 40 May 29 22:34 20-fileinfo.ini -> /etc/php/7.0/mods-available/fileinfo.ini lrwxrwxrwx 1 root root 35 May 29 22:34 20-ftp.ini -> /etc/php/7.0/mods-available/ftp.ini lrwxrwxrwx 1 root root 39 May 29 22:34 20-gettext.ini -> /etc/php/7.0/mods-available/gettext.ini lrwxrwxrwx 1 root root 37 May 29 22:34 20-iconv.ini -> /etc/php/7.0/mods-available/iconv.ini lrwxrwxrwx 1 root root 36 May 29 22:34 20-json.ini -> /etc/php/7.0/mods-available/json.ini lrwxrwxrwx 1 root root 40 May 29 22:34 20-mbstring.ini -> /etc/php/7.0/mods-available/mbstring.ini lrwxrwxrwx 1 root root 41 May 29 22:34 20-pdo_pgsql.ini -> /etc/php/7.0/mods-available/pdo_pgsql.ini lrwxrwxrwx 1 root root 37 May 29 22:34 20-pgsql.ini -> /etc/php/7.0/mods-available/pgsql.ini lrwxrwxrwx 1 root root 36 May 29 22:34 20-phar.ini -> /etc/php/7.0/mods-available/phar.ini lrwxrwxrwx 1 root root 37 May 29 22:34 20-posix.ini -> /etc/php/7.0/mods-available/posix.ini lrwxrwxrwx 1 root root 40 May 29 22:34 20-readline.ini -> /etc/php/7.0/mods-available/readline.ini lrwxrwxrwx 1 root root 37 May 29 22:34 20-shmop.ini -> /etc/php/7.0/mods-available/shmop.ini lrwxrwxrwx 1 root root 39 May 29 22:34 20-sockets.ini -> /etc/php/7.0/mods-available/sockets.ini lrwxrwxrwx 1 root root 39 May 29 22:34 20-sysvmsg.ini -> /etc/php/7.0/mods-available/sysvmsg.ini lrwxrwxrwx 1 root root 39 May 29 22:34 20-sysvsem.ini -> /etc/php/7.0/mods-available/sysvsem.ini lrwxrwxrwx 1 root root 39 May 29 22:34 20-sysvshm.ini -> /etc/php/7.0/mods-available/sysvshm.ini lrwxrwxrwx 1 root root 41 May 29 22:34 20-tokenizer.ini -> /etc/php/7.0/mods-available/tokenizer.ini /etc/php/7.0/fpm/pool.d: total 28 drwxr-xr-x 2 root root 4096 May 29 22:34 . drwxr-xr-x 4 root root 4096 May 29 22:40 .. -rw-r--r-- 1 root root 18508 May 11 23:12 www.conf /etc/php/7.0/mods-available: total 96 drwxr-xr-x 2 root root 4096 May 29 22:34 . drwxr-xr-x 5 root root 4096 May 29 22:34 .. -rw-r--r-- 1 root root 74 May 11 23:12 calendar.ini -rw-r--r-- 1 root root 71 May 11 23:12 ctype.ini -rw-r--r-- 1 root root 70 May 11 23:12 exif.ini -rw-r--r-- 1 root root 74 May 11 23:12 fileinfo.ini -rw-r--r-- 1 root root 69 May 11 23:12 ftp.ini -rw-r--r-- 1 root root 73 May 11 23:12 gettext.ini -rw-r--r-- 1 root root 71 May 11 23:12 iconv.ini -rw-r--r-- 1 root root 68 May 11 23:12 json.ini -rw-r--r-- 1 root root 76 May 11 23:12 mbstring.ini -rw-r--r-- 1 root root 79 May 11 23:12 opcache.ini -rw-r--r-- 1 root root 69 May 11 23:12 pdo.ini -rw-r--r-- 1 root root 74 May 11 23:12 pdo_pgsql.ini -rw-r--r-- 1 root root 70 May 11 23:12 pgsql.ini -rw-r--r-- 1 root root 70 May 11 23:12 phar.ini -rw-r--r-- 1 root root 71 May 11 23:12 posix.ini -rw-r--r-- 1 root root 76 May 11 23:12 readline.ini -rw-r--r-- 1 root root 71 May 11 23:12 shmop.ini -rw-r--r-- 1 root root 73 May 11 23:12 sockets.ini -rw-r--r-- 1 root root 73 May 11 23:12 sysvmsg.ini -rw-r--r-- 1 root root 73 May 11 23:12 sysvsem.ini -rw-r--r-- 1 root root 73 May 11 23:12 sysvshm.ini -rw-r--r-- 1 root root 75 May 11 23:12 tokenizer.ini

的相关流程
ps aux

我有一个用我的名字创建的用户,我正在做实际工作的sudo权限,但我不确定是否应该为该用户分配权限,或者我应该使用www-data?

1 个答案:

答案 0 :(得分:0)

此错误已解决 - 现在返回404 Not Found,这是预期的行为,因为我还没有将应用推送到服务器 - 通过修改以下/etc/nginx/sites-available/domainname

listen 80 default_server;
listen [::]:80 default_server;

修改为

listen 80 default_server;
listen [::]:80 default_server ipv6only=on;

我曾怀疑这可能是问题所在,但我确信在我之前遇到过这个问题时,我曾经尝试过这个并没有成功。无论如何,我希望这有助于将来的某个人。