Centos7-Nginx编译安装,nginx: [emerg] still could not bind()启动失败-Linux
1.nginx.org官网下载最新版本nginx,并解压源码包。#下载wget http://nginx.org/download/nginx-1.17.8.tar.gz#解压tar xf nginx-1.17.8.tar.gz2.安装依赖工具yum install gcc automake pcre-devel openssl-devel zlib-devel...
·
1.nginx.org官网下载最新版本nginx,并解压源码包。
#下载
wget http://nginx.org/download/nginx-1.17.8.tar.gz
#解压
tar xf nginx-1.17.8.tar.gz
2.安装依赖工具
yum install -y gcc automake pcre-devel openssl-devel zlib-devel
3. ./configure配置(在源码包目录下操作),自定义安装路径
#指定安装目录:--prefix=/usr/local/nginx
#安装ssl模块:--with-http_ssl_module
./configure --prefix=/usr/local/nginx --with-http_ssl_module
4.make,编译链接、生成二进制文件
make
5.make install,将编译好的相关文件拷贝到指定的安装目录中
make install
6.安装完成
7.将可执行文件路径添加到PATH(方便启动nginx)
vim ~/.bashrc
#在bashrc配置文件末尾追加nginx守护进程的路径
export PATH=$PATH:/usr/local/nginx/sbin
#保存退出后使配置文件生效
source ~/.bashrc
8.启动nginx
#启动失败
[root@server /]# 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端口是否被占用
[root@server /]# usr/sbin/lsof -i :80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
httpd 1326 root 4u IPv6 26961 0t0 TCP *:http (LISTEN)
httpd 10589 apache 4u IPv6 26961 0t0 TCP *:http (LISTEN)
httpd 10591 apache 4u IPv6 26961 0t0 TCP *:http (LISTEN)
httpd 10593 apache 4u IPv6 26961 0t0 TCP *:http (LISTEN)
httpd 10594 apache 4u IPv6 26961 0t0 TCP *:http (LISTEN)
httpd 10595 apache 4u IPv6 26961 0t0 TCP *:http (LISTEN)
#关闭httpd服务
[root@server /]# systemctl stop httpd
#成功启动
[root@server /]# nginx
9.浏览器输入主机的IP地址查看nginx主页(使用了默认端口80,所有可以不输入端口)
更多推荐
已为社区贡献3条内容
所有评论(0)