在CentOS 7下Nginx下没有WordPress的写入权限

我有一台运行Nginx的CentOS 7机器,用户是“nginx”(在CentOS中是默认的)。 我已经安装了Wordpress,这是完美的工作,我已经给wordpress文件夹和子文件夹(775)中的nginx用户的wrtite权限,但仍然会得到权限错误:

无法创build目录wp-content / uploads / 2015/05

我再次检查哪个用户正在运行nginx工作进程,它是nginx。

这一定是我错过的小事。 有人能帮我吗?

编辑:

我在/var/log/nginx/error.log中注意到了这一点:

2015/05/03 20:42:41 [error] 23652#0:* 1在stderr中发送了FastCGI:“无法打开主脚本:/usr/share/nginx/html/index.php(没有这样的文件或目录)当读取来自上游的响应报头时,客户端:XXX.XXX.XXX.A,服务器:XXX.XXX.XXX.B,请求:“GET / HTTP / 1.1”,上游:“fastcgi:// unix:/ var /运行/ php-fpm / php-fpm.sock:“,主机:”XXX.XXX.XXX.B“

2015/05/03 20:44:18 [error] 23652#0:* 3在stderr中发送了FastCGI:“无法打开主脚本:/usr/share/nginx/html/wp-admin/admin-ajax.php没有这样的文件或目录)“,而从上游读取响应头,客户端:XXX.XXX.XXX.A,服务器:XXX.XXX.XXX.B,请求:”POST /wp-admin/admin-ajax.php HTTP / 1.1“,上游:”fastcgi:// unix:/var/run/php-fpm/php-fpm.sock:“,主机:”XXX.XXX.XXX.B“,referrer:” http:// XXX。 XXX.XXX.B / wp-admin / “

2015/05/03 21:02:54 [emerg] 23803#0:getpwnam(“http”)在/etc/nginx/nginx.conf中失败:6

编辑2

$ ps -elf|grep nginx 1 S root 2045 1 0 80 0 - 27393 sigsus 15:46 ? 00:00:00 nginx: master process /usr/sbin/nginx 5 S nginx 2049 2045 0 80 0 - 27503 ep_pol 15:46 ? 00:00:00 nginx: worker process 5 S nginx 2050 2045 0 80 0 - 27503 ep_pol 15:46 ? 00:00:00 nginx: worker process 5 S nginx 2051 2045 0 80 0 - 27503 ep_pol 15:46 ? 00:00:00 nginx: worker process 5 S nginx 2052 2045 0 80 0 - 27503 ep_pol 15:46 ? 00:00:00 nginx: worker process 

服务器configuration文件是:

 server { listen 80; server_name XXX.XXX.XXX.B; location / { root /var/www/wordpress; index index.php index.html index.htm; try_files $uri $uri/ /index.php?q=$uri&$args; } error_page 404 /404.html; location = /404.html { root /usr/share/nginx/html; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } location ~ \.php$ { root /var/www/wordpress; fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } 

至于nginxconfiguration文件:

 user nginx; worker_processes 4; error_log /var/log/nginx/error.log; pid /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; keepalive_timeout 65; index index.html index.htm; include /etc/nginx/conf.d/*.conf; server { listen 80 default_server; server_name localhost; root /usr/share/nginx/html; include /etc/nginx/default.d/*.conf; location / { } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } } 

这不是用户nginx正在运行,因为这是重要的,但它是用户php-fpm运行。 毕竟,执行PHP脚本的是PHP-FPM,WordPress运行在PHP-FPM运行用户拥有的权限下。

因此,检查您的上传目录是否可以由运行PHP-FPM的用户编写。