编辑nginx.conf
- server {
- listen 80;
- server_name localhost;
- #charset koi8-r;
- #access_log logs/host.access.log main;
- location / {
- root html; ## 指向nginx 安装目录下的html文件夹,看具体配置
- index noindex.htm;
- autoindex on;
- }
- location /www/ {
- root /home/admin/; ##会指向/home/admin/www
- autoindex on; ##会自动显示资源目录
- index noindex.htm;
- }
通过浏览器范围 localhost/www/index.htm,访问时出现403。
Nginx的error.log 报以下错误: *2658 open() “/xxx/xxxx(dir path)” failed (13: Permission denied)
确定为权限问题,在nginx.conf 中增加用户配置
查看work process的所属用户
- [admin@wuzhongarch ~]$ ps -ef | grep nginx
- root 12195 1 0 15:06 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/conf/nginx.conf
- admin 12196 12195 0 15:06 ? 00:00:00 nginx: worker process
文件目录的组和权限
这样就可以正常浏览访问了。。
来源:oschina
链接:https://my.oschina.net/u/3371661/blog/4865529