准备环境
安装gcc、PCRE、zlib、OpenSSL
yum install -y gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
安装
下载安装包
wget https://nginx.org/download/nginx-1.20.1.tar.gz
解压
tar -zxvf nginx-1.20.1.tar.gz
配置
./configure --prefix=/opt/nginx --with-http_ssl_module --with-stream
编译安装
make && make install
启动、停止nginx
cd /usr/local/nginx/sbin/
./nginx
./nginx -s stop
./nginx -s quit
./nginx -s reload
Nginx加入Service服务
vim /etc/systemd/system/nginx.service
[Unit]
Description=nginx - high performance web server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/opt/nginx/logs/nginx.pid
ExecStart=/opt/nginx/sbin/nginx -c /opt/nginx/conf/nginx.conf
ExecReload=/opt/nginx/sbin/nginx -s reload
ExecStop=/opt/nginx/sbin/nginx -s stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
评论区