wget https://repo.huaweicloud.com/nginx/nginx-1.22.0.tar.gz
# 安装依赖
yum -y install gcc pcre-devel zlib zlib-devel openssl openssl-devel gcc-c++
解压到/usr/local
tar zxvf nginx-1.22.0.tar.gz
# 进入解压目录 执行
./configure
make & make install
systemctl 执行文件
cd /usr/lib/systemd/system
vim nginx.service
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
启动
# 加载
systemctl daemon-reload
#启动
systemctl start nginx
# 重启
systemctl restart nginx
# 停止
systemctl stop nginx
#开机自启
systemctl enable nginx
# 查看开机自启状态
systemctl is-enabled nginx