directory index of "/usr/share/nginx/html/" is forbidden
来源:互联网 发布:杨幂赵丽颖谁发展 知乎 编辑:程序博客网 时间:2024/06/10 14:02
安装完nginx之后访问本机ip,结果直接报错,然后去查看nginx错误日志,看到如下错误信息,意思是html下面没有
directory index of "/usr/share/nginx/html/" is forbidden
1、如果在/usr/share/nginx/html下面没有index.php,index.html
的时候,直接访问域名,找不到文件,会报403 forbidden。
解决办法:直接输入以下命令:
#删除index.html文件rm /usr/share/nginx/html/index.html#在html目录下面新建一个index.php文件,内容是`<?php phpinfo(); ?>` 查看phpinfoecho "<?php phpinfo(); ?>" >> /usr/share/nginx/html/index.php
2、还有一个原因就是你的默认的nginx配置文件的location没有指定root路径,我的就是这个问题。
这个就直接在默认的server上面加上:
location / { root html; index index.php index.html index.htm;}
3、如果还是不能正常访问,那就进到nginx的默认配置文件里去找一下,看看有没有如下代码:
location ~* \.php$ { fastcgi_index index.php; fastcgi_pass 127.0.0.1:9000; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name;}
上面代码的意思是把php文件交给php-fpm处理,php-fpm占用的端口号是9000。
配置完以后,记得重启nginx,或者reload一下:
重启nginx:
nginx -s stopnginx
或者:
nginx -s reopen
下面是重新加载nginx的配置文件(推荐这种方式):
service nginx reload
找到nginx的安装目录:
[root@localhost nginx]# which nginx/usr/sbin/nginx #这个是yum安装后默认所在位置
查看nginx的命令提示:
[root@localhost nginx]# nginx -hnginx version: nginx/1.10.2Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives]Options: -?,-h : this help -v : show version and exit -V : show version and configure options then exit -t : test configuration and exit -T : test configuration, dump it and exit -q : suppress non-error messages during configuration testing -s signal : send signal to a master process: stop, quit, reopen, reload -p prefix : set prefix path (default: /usr/share/nginx/) -c filename : set configuration file (default: /etc/nginx/nginx.conf) -g directives : set global directives out of configuration file
阅读全文
0 0
- directory index of "/usr/share/nginx/html/" is forbidden
- 关于nginx报错/usr/share/nginx/html/jiankongshare" failed (2: No such file or directory)的问题解决
- Directory index forbidden by Options directive: /var/www/html/
- /usr/share/nginx/sbin/nginx
- apache报错: Directory index forbidden by Options directive: /var/www/html
- nginx: [emerg] open() "/usr/local/nginx/logs/access.log" failed (21: Is a directory)
- 错误:/usr/share/man/windex: No such file or directory
- apache Directory index forbidden by Options directive 错误解决方法
- nginx访问报错403 is forbidden
- svn Changing directory 'xxxxxxx' is forbidden by the server 解决方案
- 解决could not find /usr/bin/../share/httrack/html
- nginx去掉index.html改为index.php
- mkdir: cannot create directory `/usr/local/share/man/man1': File exists
- /usr/bin/ld:cannot open output file:Is a directory
- Apache 不能列目录解决 -- server-generated directory index forbidden by Options directive
- Mac MAMP 安装 tp5 出现 apache Directory index forbidden by Options directive 错误解决方法
- Centos7 nginx修改文件夹后 is forbidden (13: Permission denied)
- nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)
- 使用SShCoient软件向linex传送文件报错:Encountered 1 errors during the transfer
- PHP Excel上传demo
- js中利用prototype给类添加方法
- MyBatis3 用log4j在控制台输出 SQL
- hdoj 1094
- directory index of "/usr/share/nginx/html/" is forbidden
- js 阻止事件捕获
- 回车提交表单
- Springboot 实现 Restful 服务,基于 HTTP / JSON 传输
- 1070. 结绳(25) PAT
- [USACO2.1]城堡 The Castle
- RN学习1——前奏,app插件化和热更新的探索
- tcp协议系列文章(5):select:同步I/O复用
- hdoj 1095