Ngnix 安装启动与 bind端口出错解决

 

                                                Ngnix 安装

Linux系统是Centos 6.5 64位,我直接切换到root用户下安装

进入目录:

下载相关组件

wget http://nginx.org/download/nginx-1.10.2.tar.gz
wget http://www.openssl.org/source/openssl-fips-2.0.10.tar.gz
wget http://zlib.net/zlib-1.2.11.tar.gz
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz

 

安装c++编译环境,如已安装可略过

yum install gcc-c++

期间会有个输入: y

2、安装Nginx及相关组件

openssl安装

cd /usr/local 
mkdir openssl
cd /usr/software
tar zxvf openssl-fips-2.0.10.tar.gz -C /usr/local/openssl/
cd /usr/local/openssl/openssl-fips-2.0.10
./config && make && make install

pcre安装 

cd /usr/local 
mkdir pcre 
cd /usr/software
tar zxvf pcre-8.40.tar.gz -C  /usr/local/pcre/
cd /usr/local/pcre/
cd pcre-8.40
./configure && make && make install

zlib安装

cd /usr/local 
mkdir  zlib 
cd /usr/software 
tar zxvf zlib-1.2.11.tar.gz -C /usr/local/zlib/
cd /usr/local/zlib/zlib-1.2.11/
./configure && make && make install

nginx安装

cd /usr/local 
mkdir  nginx
cd /usr/software 
tar zxvf nginx-1.10.2.tar.gz -C /usr/local/nginx/
cd /usr/local/nginx/nginx-1.10.2/
./configure && make && make install

 

3、启动Nginx

进入nginx目录并启动

/usr/local/nginx/sbin
./nginx
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()

报错绑定不了

进入目录:/usr/local/nginx/nginx-1.10.2/conf

修改nginx.conf

修改nginx端口 为81 

再次启动

telnet 172.31.1.135 81

 

防火墙关闭

service iptables stop

添加nginx映射

vi nginx.conf
location  / {
                proxy_pass http://39.107.125.254:8080/springwebdemo/loginaction.do?op=tologin;
                proxy_set_header Host $host:8080;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Via "nginx";
         }
#刷新配置
./nginx -s reload

 

 

Nginx负载均衡配置

 

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

wangxiaoming

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值