编辑nginx.conf
Java代码
- 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 中增加用户配置
- user admin users;
查看work process的所属用户
Html代码
- [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
文件目录的组和权限
Html代码
- [admin@wuzhongarch ~]$ ll | grep www
- drwxr-xr-x 4 admin users 4096 Feb 2 15:05 www/
这样就可以正常浏览访问了。。
本文暂时没有评论,来添加一个吧(●'◡'●)