nginx页面不能正常访问排除方法
来源:互联网 发布:蓝宝石之谜 知乎 编辑:程序博客网 时间:2024/04/27 10:17
nginx页面不能访问
- nginx页面不能访问
- 检查服务端服务是否启动成功
- 在服务端使用wget和curl测试下返回的是否正常
- 浏览器wget或者curl等软件访问不了Ngixn页面
1. 检查服务端服务是否启动成功
[root@shizhan02 html]# ps -ef |grep nginx #查看nginx服务是否启动root 1609 1 0 16:46 ? 00:00:00 nginx: master process nginxnginx 1610 1609 0 16:46 ? 00:00:00 nginx: worker processroot 1898 1593 0 18:09 pts/0 00:00:00 grep nginx
[root@shizhan02 html]# lsof -i :80 #检查80端口是否在监听状态COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEnginx 1609 root 6u IPv4 11948 0t0 TCP *:http (LISTEN)nginx 1610 nginx 6u IPv4 11948 0t0 TCP *:http (LISTEN)
[root@shizhan02 html]# netstat -lnt |grep 80 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
2.在服务端使用wget和curl测试下返回的是否正常
[root@shizhan02 html]# wget 127.0.0.1--2017-11-20 18:16:58-- http://127.0.0.1/Connecting to 127.0.0.1:80... connected.HTTP request sent, awaiting response... 200 OK #返回值200表示链接正常Length: 612 [text/html]Saving to: “index.html.2”100%[===============================================================>] 612 --.-K/s in 0s 2017-11-20 18:16:58 (279 MB/s) - “index.html.2” saved [612/612][root@shizhan02 html]# curl 127.0.0.1 #返回页面的值表示正常。<!DOCTYPE html><html><head><title>Welcome to nginx!</title><style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; }</style></head><body><h1>Welcome to nginx!</h1><p>If you see this page, the nginx web server is successfully installed andworking. Further configuration is required.</p><p>For online documentation and support please refer to<a href="http://nginx.org/">nginx.org</a>.<br/>Commercial support is available at<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p></body></html>
以上是检测Nginx在服务端安装及浏览是否正常。
3.浏览器,wget或者curl等软件访问不了Ngixn页面。
1. 关闭SEliun ``` [root@shizhan02 html]# getenforce #查看iptables状态,是否为关闭,以下为关闭状 态, Disabled [root@shizhan02 html]# vim /etc/selinux/config #永久关闭iptalbes SELINUX=disabled #需要将此行更改为disabled SELINUXTYPE=targeted [root@shizhan02 html]# setenforce 0 #临时关闭iptables的方法,如果临时能够访问 了,那么久使用下面的方法添加80端口在iptables的配置文件上 setenforce: SELinux is disabled [root@shizhan02 html]# service iptables status #检查iptables Table: filter Chain INPUT (policy ACCEPT) num target prot opt source destination Chain FORWARD (policy ACCEPT) num target prot opt source destination Chain OUTPUT (policy ACCEPT) num target prot opt source destination 问题不是出在nginx上,而是出在iptable上,在iptable上添加80端口 Linux代码 收藏代码 #vi /etc/sysconfig/iptables //在倒数第二行加入80端口 -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT //重启iptables #/etc/init.d/iptables restart 再通过ip访问 ok~ 没问题了 ```2. 通过本地客服端测试 第一步:在客服端ping服务端的ip,我这里的的服务端为192.168.1.202 ``` [root@shizhan02 html]# ping 192.168.1.202 PING 192.168.1.202 (192.168.1.202) 56(84) bytes of data. 64 bytes from 192.168.1.202: icmp_seq=1 ttl=64 time=0.014 ms 64 bytes from 192.168.1.202: icmp_seq=2 ttl=64 time=0.024 ms ^C --- 192.168.1.202 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1814ms rtt min/avg/max/mdev = 0.014/0.019/0.024/0.005 ms #提示按ctrl+c结束 ``` 第二步:在客户端上telnet服务端ip,端口 ``` [root@shizhan02 html]# telnet 192.168.1.202 #返回如下信息表示链接成功 Trying 192.168.1.202... telnet: connect to address 192.168.1.202: Connection refused ``` 第三步:在客服端使用wget或者curl命令检测。 ``` [root@shizhan02 html]# curl -i 192.168.1.202 HTTP/1.1 200 OK Server: nginx/1.13.6 Date: Mon, 20 Nov 2017 10:42:31 GMT Content-Type: text/html Content-Length: 612 Last-Modified: Mon, 20 Nov 2017 08:08:26 GMT Connection: keep-alive ETag: "5a128d7a-264" Accept-Ranges: bytes <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx!</h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p> <p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p> </body> </html> ``` 3. 在浏览器访问输入如下的内容,服务器ip. http://192.168.1.202/ ![nginx已经能够成功访问](http://img.blog.csdn.net/20171120104737429?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXFfMjk3NjczMTc=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast) 这里有一个小小的坑,希望大家注意一下,使用浏览器输入ip访问的时候,注意清空一下缓存,或者重新打开一下浏览器,有可能让你一直刷新不出页面。
阅读全文
1 0
- nginx页面不能正常访问排除方法
- 不能正常引用ADOX故障排除
- fedora20安装nginx不能访问处理方法
- 网站不能正常访问原因分析几处理方法
- tomcat 启动正常 不能访问
- eclipse中tomcat正常启动但不能访问tomcat管理页面的解决方法
- tomcat后台日志启动正常,但是不能访问http://ip:8080页面
- 打印机不能打印的日常排除方法
- nginx 静态页面访问
- 解决XP系统下局域网不能正常访问的部分方法
- Nginx由于TLS支持版本配置过低造成不能够正常访问Upstream服务器的问题
- 这两天MSN Space不能正常访问
- 修改上传后不能正常访问
- Wordpress更换ip不能正常访问解决方法
- jsp中文路径图片不能正常访问
- cajviewer 文件不存在或不能正常访问
- 链接带有中文不能正常访问
- nginx配置好了不能访问
- tp5.0路由配置相关
- 开启Word2013格式跟踪功能
- 短视频,究竟“多短”才算短?
- 不要讨要共享单车押金了,没用
- 乐视系员工股权被“清零”;小米新总部正式落户武汉;特斯拉电动卡车获多份订单丨价值早报
- nginx页面不能正常访问排除方法
- 百度前200面试
- 创投日报:11月17日~19日收录投融资项目18起
- Guacamole 介绍以及架构 及安装
- Out of range value for column 'hxGroupId' at row 1
- wx分享介入
- 《剑破冰山-Oracle开发艺术》学习记录
- Android 4.4.2 系统源码字体库精简、添加
- UVA 10943 How do you add?——背包