Nginx build install

Ubuntu 安装

sudo apt-get update
#安装依赖:gcc、g++依赖库
sudo apt-get install build-essential libtool
#安装 pcre依赖库(http://www.pcre.org/)
sudo apt-get install libpcre3 libpcre3-dev
#安装 zlib依赖库(http://www.zlib.net)
sudo apt-get install zlib1g-dev
#安装ssl依赖库
sudo apt-get install openssl

下载Nginx源码

下载-解压-重命名

wget https://nginx.org/download/nginx-1.20.1.tar.gz
tar -xvf nginx-1.20.1.tar.gz
mv nginx-1.20.1.tar.gz  /usr/local/nginx
cd nginx

进入nginx 目录 执行编译命令

sudo ./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/nginx.conf --with-pcre-jit --with-pcre --with-http_ssl_module --with-http_v2_module --with-http_addition_module --with-http_image_filter_module --with-http_sub_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_slice_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-http_sub_module --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module
sudo make && make install
cd sbin
sudo ./nginx -t

Syntax is ok 表示安装成功

Centos 安装

 #安装gcc
 sudo yum -y install gcc gcc-c++
 #安装pcre
 sudo yum -y install pcre pcre-devel
 #安装 zlib,zlib 库提供了很多压缩和解压缩的方式
 sudo yum -y install zlib zlib-devel
 #安装 openssl,安全套接字层密码库,用于通信加密
 sudo yum -y install openssl openssl-devel

将下载好的nginx源码进行解压编译

wget https://nginx.org/download/nginx-1.20.1.tar.gz
tar -xvf nginx-1.20.1.tar.gz
mv nginx-1.20.1.tar.gz  /usr/local/nginx
cd nginx
sudo ./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/nginx.conf --with-pcre-jit --with-pcre --with-http_ssl_module --with-http_v2_module --with-http_addition_module --with-http_image_filter_module --with-http_sub_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_slice_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-http_sub_module --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module
sudo make && make install
cd sbin
sudo ./nginx -t

参数说明

上一篇