Nginx 中的 Wordpress 访问和权限被拒绝

Nginx 中的 Wordpress 访问和权限被拒绝

我一直在尝试让 wordpress 与 nginx 协同工作,这对我来说是个新任务,但我快完成了。
但最后还是无法让 wordpress 工作。我尝试了所有我能尝试的方法,但问题完全一样,解决方案也得到了批准,但对我来说没用。

017/01/28 10:54:22 [crit] 3576#3576: *65 stat() "/home/wptask/public_html/wp-admin/install.php" failed (13: Permission denied), client: 127.0.0.1, server: firtswebsite.com, request: "GET /wp-admin/install.php HTTP/1.1", host: "127.0.0.1"
2017/01/28 10:53:36 [crit] 3576#3576: *1 stat() "/home/wptask/public_html/wp-admin/install.php" failed (13: Permission denied), client: 192.168.10.1, server: firtswebsite.com, request: "GET /wp-admin/install.php HTTP/1.1", host: "192.168.10.10"

我做了这个

chmod +x /home
chmod +x /home/wptask
chmod +x /home/wptask/public_html 
sudo chown -R wptask:wptask /home/wptask
chmod go-rwx /home/wptask
chmod go+x /home/wptask
chgrp -R wptask /home/wptask
chmod -R go-rwx /home/wptask
chmod -R g+rx /home/wptask
chmod -R g+rwx /home/wptask

乃至chmod 755 /home/wptask

但对我不起作用

更新:- ls -l 用于 webroot

[root@web-srv ~]# ls -l /home/wptask/
drwxr-sr-x. 2 root root   41 Jan 30 07:01 logs
drwxr-sr-x. 5 root root 4096 Jan 28 08:41 public_html

nginx.conf

    user  nginx;
    worker_processes  1;

    error_log  /var/log/nginx/error.log warn;

pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    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  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/sites-enabled/*;
    include /etc/nginx/conf.d/*.conf;
}

修复更新:-

ls -l webroot

[root@web-srv ~]# ls -l /home/wptask/
total 4
drwxr-s---. 2 wptask wptask   41 Jan 30 07:01 logs
drwxr-s---. 5 wptask wptask 4096 Jan 28 08:41 public_html

我在 nginx.conf 中更改了 nginx 用户

答案1

您的文件权限与 Nginx 以何种用户身份运行有关。您没有向我们提供足够的信息来帮助我们,例如 nginx 以谁的身份运行 ( ps -u | grep nginx ) 或存储内容的位置。

我有一个教程应该可以帮到你,这里. 关键部件包括

useradd tim   (NB: you can name the user something else if you like!)
passwd tim    (NB: give them a secure password, but you'll never need to use it)
groupadd www-data
usermod -a -G www-data nginx   (add the nginx user to the www-data group)
chown -R tim /usr/share/nginx/
chgrp -R www-data /usr/share/nginx/
chmod -R 750 /usr/share/nginx/
chmod -R g+s /usr/share/nginx/

这是基于Wordpress 权限文档

相关内容