Centos 安装 Nginx
Centos版本:8.4
Nginx版本:1.20.2
下载地址:http://nginx.org/en/download.html
上传目录:/usr/local/src/
安装目录:/usr/local/nginx
编译安装
# 查看版本号
cat /etc/redhat-release
# 解压
tar zxf nginx-1.20.1.tar.gz cd nginx-1.20.1/
# 配置 ./configure --prefix=/usr/local/nginx --with-pcre --with-http_ssl_module
# 编译,安装
make && make install
# 添加环境变量
echo "export PATH=$PATH:/usr/local/nginx/sbin" >> /etc/profile
source /etc/profile
问题集锦
./configure: error: C compiler cc is not found
yum install -y gcc-c++
./configure: error: the HTTP rewrite module requires the PCRE library
yum install -y pcre-devel
./configure: error: SSL modules require the OpenSSL library
yum install -y openssl-devel
bash: make: command not found
yum install -y make
nginx: [emerg] bind() to 0.0.0.0:80 failed ()98: address already in use)
# 查看端口使用情况,终止进程
netstat -antp | grep 80
kill PID
nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)
# 创建配置文件
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf