centos 安装 nginx(新)
2021-09-12 本文已影响0人
骑着小猪看大海
参考这篇文章
https://www.cnblogs.com/yunqishequ/p/10070008.html
1. 下载 nginx 包
cd /usr/local
wget http://nginx.org/download/nginx-1.17.0.tar.gz
2. 安装 nginx 依赖库
yum install gcc-c++
yum install pcre
yum install pcre-devel
yum install zlib
yum install zlib-devel
yum install openssl
yum install openssl-devel
3. 解压安装包
tar -zxvf nginx-1.17.0.tar.gz
4. 安装 Brotli
cd /opt
git clone https://github.com/eustas/ngx_brotli.git
cd ngx_brotli
git submodule update --init --recursive
5. 进入文件夹
cd nginx-1.17.0
6. 执行# ./configure
./configure --prefix=/usr/local/nginx --with-openssl-opt=enable-tls1_3 --with-http_v2_module --with-http_ssl_module --with-http_gzip_static_module --add-module=/opt/ngx_brotli
7. 执行make和make install编译nginx
make
make install
8. 备份原有已安装好的nginx
cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
9. 然后将刚刚编译好的nginx覆盖掉原有的nginx(这个时候nginx要停止状态)
cp ./objs/nginx /usr/local/nginx/sbin/
10. 然后启动nginx,仍可以通过命令查看是否已经加入成功
./nginx