下载:
1:
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博客