nginx-1.18.0.tar.gz
2. 解压缩nginxtar -zxvf nginx-1.18.0.tar.gz
3. 进入nginx-1.18目录进行编译cd nginx-1.18
./configure
此时报错:./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=
(需要安装依赖的pcre、openssl、zlib库)
yum -y install pcre
yum -y install openssl
yum -y install zlib
(无法使用yum的情况,需要下载安装包)
pcre-8.44.tar.gz
tar zxvf pcre-8.44.tar.gz
tar zxvf openssl-1.1.1l.tar.gz
tar zxvf zlib-1.2.11.tar.gz
cd nginx-1.18
./configure --prefix=/nginx/nginx --with-openssl=/nginx/openssl-1.1.1l --with-pcre=/nginx/pcre-8.44 --with-zlib=/nginx/zlib-1.2.11
make && make install
*报错:configure: error: Invalid C++ compiler or C++ compiler flags
这是因为系统缺失 gcc-c++ 库,需要使用root安装gcc-c++环境:
yum -y install gcc-c++
yum install -y gcc
完成后再次执行make就可以了
cd /nginx/nginx/sbin
./nginx
报错:nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)
以非root权限启动时,会出现 nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied) 错误,将 /usr/local/nginx/conf/nginx.conf 文件中的80端口改为1024以上(8080)
curl http://ip:8080
Welcome to nginx! Welcome to nginx!If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.Thank you for using nginx.



