Nginx
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 網路根目錄
[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 使用者
對於執行 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 權限文件。