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负载均衡配置

 

 

 

wangxiaoming CSDN认证博客专家 架构 Spring Boot Redis
博客是很好的总结和记录工具,如果有问题,来不及回复,关注微信公众号:程序员开发者社区,获取我的联系方式,向我提问,也可以给我发送邮件,联系 1275801617@qq.com
©️2020 CSDN 皮肤主题: Age of Ai 设计师:meimeiellie 返回首页
实付 19.89元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值