- 安装编译Nginx所需的依赖项:
sudo apt update
sudo apt install libgd-dev libpcre3 libpcre3-dev build-essential zlib1g-dev libssl-dev -y
- 下载Nginx 1.24.0源代码包:
wget http://nginx.org/download/nginx-1.24.0.tar.gz
- 解压源代码包:
tar -xvf nginx-1.24.0.tar.gz
cd nginx-1.24.0
- 配置编译选项和模块:
./configure --prefix=/usr/local/nginx \
--with-pcre \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-http_image_filter_module \
--with-http_slice_module \
--with-mail \
--with-threads \
--with-file-aio \
--with-stream \
--with-mail_ssl_module \
--with-stream_ssl_module
- 编译源代码:
make
- 安装已编译的二进制文件和相关文件:
sudo make install
- 验证安装是否成功:
cd /usr/local/nginx && ./sbin/nginx -v