Nginx安装(Linux版)

下载:

1:

nginx: download

2:

在linux下操作:

解压

tar -zxvf

安装gcc

yum install -y gcc

安装perl库

yum install -y pcre pcre-devel

安装zlib库

yum install -y zlib zlib-devel

make

make install

编译安装Nginx
./configure --prefix=/usr/local/nginx
make

make install

执行

./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()
原因是端口号80被其它程序或文件占用了,那么就干掉这个程序吧
sudo fuser -k 80/tcp
fuser -k 80/tcp

Nginx常用命令(cd /usr/local/nginx/sbin/
./nginx  启动
./nginx -s stop  停止
./nginx -s quit  安全退出
./nginx -s reload  重新加载配置文件
ps aux|grep nginx  查看nginx进程

注意:如何连接不上,检查阿里云安全组是否开放端口,或者服务器防火墙是否开放端口! 相关命令:

# 开启
service firewalld start
# 重启
service firewalld restart
# 关闭
service firewalld stop
# 查看防火墙规则
firewall-cmd --list-all
# 查询端口是否开放
firewall-cmd --query-port=8080/tcp
# 开放80端口
firewall-cmd --permanent --add-port=80/tcp
# 移除端口
firewall-cmd --permanent --remove-port=8080/tcp
​
#重启防火墙(修改配置后要重启防火墙)
firewall-cmd --reload
​
# 参数解释
1、firwall-cmd:是Linux提供的操作firewall的一个工具;
2、--permanent:表示设置为持久;
3、--add-port:标识添加的端口;

使用:(配置Nginx)

upstream lb{
    server 127.0.0.1:8080 weight=1;
    server 127.0.0.1:8081 weight=1;
}

location / {
    proxy_pass http://lb;
}

【Nginx】彻底卸载Nginx以及安装Nginx的详细教程_归~海的博客-CSDN博客_卸载nginx

Nginx [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)_寻墨roy的博客-CSDN博客

【故障集合】综合架构之nginx服务错误集合(持续补充中)_文娟.狼剩的博客-CSDN博客

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值