Linux安装NGINX

2023-12-22 22:49:31

0.下载nginx源码

wget https://nginx.org/download/nginx-1.24.0.tar.gz

1.安装nginx所需依赖

apt-get install -y gcc
apt-get install -y libpcre3 libpcre3-dev
apt-get install -y zlib1g zlib1g-dev
apt-get install -y openssl?
apt-get install -y libssl-dev

由于nginx安装ssl模块需要OpenSSL源码,故需要下载解压,
并通过--with-openssl指定

wget https://www.openssl.org/source/openssl-3.2.0.tar.gz --no-check-certificate

2.执行预编译(更多配置https://nginx.org/en/docs/configure.html)

./configure \
--prefix=/root/app/nginx \
--conf-path=/root/app/nginx/nginx.conf \
--pid-path=/root/app/nginx/nginx.pid \
--sbin-path=/root/app/nginx/nginx \
--with-openssl=/root/app/openssl-3.2.0 \
--user=$USER \
--with-http_ssl_module \
--with-poll_module \
--with-http_v2_module \
--with-stream \
--with-stream_ssl_module

3.执行编译和安装(需在configure 同级路径执行)

make && make install

4.测试/启动/重启/停止

cd /root/app/nginx
./nginx -t
./nginx
./nginx -s reload
./nginx -s stop

附:

NGINX官网

OpenSSL官网

文章来源:https://blog.csdn.net/gengzhy/article/details/135161853
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。