这几天有点闲不住/*明明都期末考试了*/,把之前很多搁置的项目和老物件都拿出来折腾了一番,也遇到了不少问题。
之前Silver Sky Studio主站的服务器搭建的时候由于Nginx和php-fpm用的不是同一个用户造成了一些麻烦,现在在搭建的新的环境的时候就考虑了这个问题。
/*这台服务器SSS-NAS0,之前有配置过Nginx+php-fpm,但是荒废掉了,这次重新拿出来只是更改了下配置文件*/
Nginx原先的用户名为nginx,改为www-data
而php-fpm原先的用户名为www-data就不改了
设置好网站目录的权限后 进入网站后台发现一些页面CSS还有其他文件加载不出来
查看Nginx错误日志,部分如下:
2016/01/17 10:23:20 [crit] 4167#0: *1 open() “/var/cache/nginx/fastcgi_temp/1/00/0000000001” failed (13: Permission denied) while reading upstream, client: 123.130.15.161, server: skyline, request: “GET /wp-admin/load-styles.php?c=1&dir=ltr&load=dashicons,admin-bar,wp-admin,buttons&ver=4.4.1 HTTP/1.1”, upstream: “fastcgi://127.0.0.1:9000”, host: “silversky.moe:404”, referrer: “http://silversky.moe:404/wp-admin/update-core.php?action=do-theme-upgrade”
2016/01/17 10:23:22 [crit] 4167#0: *7 open() “/var/cache/nginx/fastcgi_temp/2/00/0000000002” failed (13: Permission denied) while reading upstream, client: 123.130.15.161, server: skyline, request: “GET /wp-admin/load-styles.php?c=1&dir=ltr&load=dashicons,admin-bar,wp-admin,buttons&ver=4.4.1 HTTP/1.1”, upstream: “fastcgi://127.0.0.1:9000”, host: “silversky.moe:404”, referrer: “http://silversky.moe:404/wp-admin/update-core.php?action=do-theme-upgrade”
2016/01/17 10:24:12 [crit] 4167#0: *3 open() “/var/cache/nginx/fastcgi_temp/3/00/0000000003” failed (13: Permission denied) while reading upstream, client: 123.130.15.161, server: skyline, request: “GET /wp-admin/load-styles.php?c=1&dir=ltr&load=dashicons,admin-bar,wp-admin,buttons&ver=4.4.1 HTTP/1.1”, upstream: “fastcgi://127.0.0.1:9000”, host: “silversky.moe:404”, referrer: “http://silversky.moe:404/wp-admin/update-core.php?action=do-theme-upgrade”
也就是说www-data用户对/var/cache/nginx/fastcgi_temp/3/00/0000000003没有足够的权限
重新chown /var/cache/nginx/fastcgi_temp之后问题解决
#chown -R www-data:www-data /var/cache/nginx/fastcgi_temp