nginx部署(centos系统)--访问失败404
2018-07-12 16:40
281 查看
一、说明
系统:centos 6.6
nginx版本:nginx-1.8.0
二、nginx安装
安装步骤
(1)安装依赖包:gcc,pcre,zlib,openssl
(2)安装nginx-1.8.0
1、安装依赖包:
cd /usr/local yum install -y gcc gcc-c++ yum install -y pcre pcre-devel yum install -y zlib zlib-devel yum install -y openssl openssl-devel
2、安装nginx-1.8.0
wget http://nginx.org/download/nginx-1.8.0.tar.gz tar -zxvf nginx-1.8.0.tar.gz cd nginx-1.8.0 ./configure --user=nobody --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_sub_module --with-http_ssl_module make install ls ../ cd ../nginx cd sbin/ ./nginx ps -ef | grep nginx root 1821 1 0 00:44 ? 00:00:00 nginx: master process ./nginx nobody 1822 1821 0 00:44 ? 00:00:00 nginx: worker process root 1824 1753 0 00:44 pts/0 00:00:00 grep nginx
在本机浏览器访问部署nginx的80端口http://...:80,显示图下页面即为部署成功。
至此nginx安装完毕。
3、修改配置文件
需要同时部署2个,
cd /usr/local/nginx/conf cp nginx nginx.bak vi nginx
启动异常,报错如下图,检查error.log报错
2018/07/12 17:37:18 [emerg] 5555#0: bind() to 0.0.0.0:1090 failed (98: Address already in use) 2018/07/12 17:37:18 [emerg] 5555#0: bind() to 0.0.0.0:8380 failed (98: Address already in use) 2018/07/12 17:37:18 [emerg] 5555#0: bind() to 0.0.0.0:1090 failed (98: Address already in use) 2018/07/12 17:37:18 [emerg] 5555#0: bind() to 0.0.0.0:8380 failed (98: Address already in use) 2018/07/12 17:37:18 [emerg] 5555#0: bind() to 0.0.0.0:1090 failed (98: Address already in use) 2018/07/12 17:37:18 [emerg] 5555#0: bind() to 0.0.0.0:8380 failed (98: Address already in use) 2018/07/12 17:37:18 [emerg] 5555#0: bind() to 0.0.0.0:1090 failed (98: Address already in use) 2018/07/12 17:37:18 [emerg] 5555#0: bind() to 0.0.0.0:8380 failed (98: Address already in use) 2018/07/12 17:37:18 [emerg] 5555#0: bind() to 0.0.0.0:1090 failed (98: Address already in use) 2018/07/12 17:37:18 [emerg] 5555#0: bind() to 0.0.0.0:8380 failed (98: Address already in use) 2018/07/12 17:37:18 [emerg] 5555#0: still could not bind()
检查网站的error.log
2018/07/12 01:37:28 [error] 2880#0: *45 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.23.254, server: www.***.cn, request: "GET /favicon.ico HTTP/1.1", upstream: "http://12.1.11.20:8080/*-**/html/*/index.***.ico", host: "192.168.23.22:8380", referrer: "http://192.168.23.22:8380/" 2018/07/12 01:37:28 [error] 2880#0: *45 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.23.254, server: www.***.cn, request: "GET / HTTP/1.1", upstream: "http://12.1.11.20:8080/***/html/**/index.html", host: "192.168.23.22:8380"
百度搜索错误
“(111: Connection refused) while connecting to upstream” 用户在连接时,若遇到后端upstream挂掉或者不通,会收到该错误
检查端口调用情况
netstat -ntlp
杀掉nginx进程发现,杀掉一次,还有一次,才彻底杀完。
[root@nginx22 nginx]# netstat -ntlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1493/sshd tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1365/cupsd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1597/master tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 5497/sshd tcp 0 0 0.0.0.0:8380 0.0.0.0:* LISTEN 1821/nginx tcp 0 0 0.0.0.0:1090 0.0.0.0:* LISTEN 1821/nginx tcp 0 0 0.0.0.0:49831 0.0.0.0:* LISTEN 1215/rpc.statd tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1195/rpcbind tcp 0 0 :::22 :::* LISTEN 1493/sshd tcp 0 0 ::1:631 :::* LISTEN 1365/cupsd tcp 0 0 ::1:25 :::* LISTEN 1597/master tcp 0 0 ::1:6010 :::* LISTEN 5497/sshd tcp 0 0 :::58432 :::* LISTEN 1215/rpc.statd tcp 0 0 :::111 :::* LISTEN 1195/rpcbind [root@nginx22 nginx]# kill -9 1821 [root@nginx22 nginx]# netstat -ntlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1493/sshd tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1365/cupsd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1597/master tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 5497/sshd tcp 0 0 0.0.0.0:8380 0.0.0.0:* LISTEN 5529/nginx tcp 0 0 0.0.0.0:1090 0.0.0.0:* LISTEN 5529/nginx tcp 0 0 0.0.0.0:49831 0.0.0.0:* LISTEN 1215/rpc.statd tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1195/rpcbind tcp 0 0 :::22 :::* LISTEN 1493/sshd tcp 0 0 ::1:631 :::* LISTEN 1365/cupsd tcp 0 0 ::1:25 :::* LISTEN 1597/master tcp 0 0 ::1:6010 :::* LISTEN 5497/sshd tcp 0 0 :::58432 :::* LISTEN 1215/rpc.statd tcp 0 0 :::111 :::* LISTEN 1195/rpcbind [root@nginx22 nginx]# kill -9 5529 [root@nginx22 nginx]# netstat -ntlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1493/sshd tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1365/cupsd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1597/master tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 5497/sshd tcp 0 0 0.0.0.0:49831 0.0.0.0:* LISTEN 1215/rpc.statd tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1195/rpcbind tcp 0 0 :::22 :::* LISTEN 1493/sshd tcp 0 0 ::1:631 :::* LISTEN 1365/cupsd tcp 0 0 ::1:25 :::* LISTEN 1597/master tcp 0 0 ::1:6010 :::* LISTEN 5497/sshd tcp 0 0 :::58432 :::* LISTEN 1215/rpc.statd tcp 0 0 :::111 :::* LISTEN 1195/rpcbind
测试wget及curl返回值是否正常
[root@nginx22 logs]# netstat -lnt |grep 8180 tcp 0 0 0.0.0.0:8180 0.0.0.0:* LISTEN [root@nginx22 logs]# wget 127.0.0.1 --2018-07-12 23:14:43-- http://127.0.0.1/ 正在连接 127.0.0.1:80... 失败:拒绝连接。 [root@nginx22 logs]# curl 127.0.0.1 curl: (7) couldn't connect to host
为什么?
还未解决,待解救。
相关文章推荐
- tomcat中部署项目后,访问失败,报错404的原因以及解决方案
- nginx配置vue-router+webpack项目部署访问刷新出现404问题
- centos系统,基于nginx服务器,用https访问php页面总弹出下载页面问题完美解决
- 关于LINUX系统下部署javaweb项目失败报错404的问题
- CentOS7中firewall浏览器访问失败nginx
- 在centos上用nginx访问php显示404
- 创 nginx v1.4.6 部署ThinkPHP 页面访问404 -- 酱油小君搬砖记
- 部署Asp.net系统时页面访问Oracle 10G数据库失败
- CentOS6.3添加nginx php-fpm系统服务详细说明
- CentOS 6.5 x86_64 系统定制自动化部署
- Linux 下部署了Nginx服务器,始终外网无法访问
- Linux(CentOS6.5)下Nginx注册系统服务(启动、停止、重启、重载等)&设置开机自启
- 如何在CentOS 6上 及 ubantu 通过安装 PHP + Nginx 及扩展(完整部署)
- cmd 启动mysql失败 net start/stop mysql 发生系统错误5.拒绝访问
- 宿机archlinux 上运行Docker CentOS7.2,安装nginx.并且宿机中访问docker中的nginx网站
- 【天坑】springboot打包成war,部署到tomcat,访问404
- nginx在linux系统下的安装部署,以及反向代理https请求协议,ssl证书的生成,负载均衡tomcat服务器!
- Cobbler自动化批量部署CentOS6.5系统
- centos7.0 64位系统 安装PHP 支持 nginx
- VMware station 10 上部署Centos 7 系统