nginx 代理本地的html

编辑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 中增加用户配置

user admin users;
 

 

查看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 
 

文件目录的组和权限

[admin@wuzhongarch ~]$ ll | grep www
drwxr-xr-x  4 admin users     4096 Feb  2 15:05 www/
 

这样就可以正常浏览访问了。。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值