NGINX的安装部署

image

一、版本区别

常用版本分为四大阵营:

二、源码编译安装

$ yum install gcc pcre pcre-devel zlib zlib-devel -y
# 安装依赖

$ wget http://nginx.org/download/nginx-1.21.6.tar.gz
$ tar zxf nginx-1.21.6.tar.gz -C /usr/src/
$ cd /usr/src/
$ ln -s nginx-1.21.6/ nginx
$ cd nginx
$ ./configure --prefix=/usr/local/nginx
$ make && make install

启动nginx:

./nginx					    # 启动
./nginx -s stop			 	#快速停止
./nginx -s quit 			#优雅关闭,在退出前完成已经接受的连接请求
./nginx -s reload 			#重新加载配置

三、配置为系统服务

$ vi /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx - web server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
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 stop
ExecQuit=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true

[Install]
WantedBy=multi-user.target

$ systemctl daemon-reload
$ systemctl start nginx.service
$ systemctl enable nginx.service
posted @ 2022-07-04 21:28  吕振江  阅读(31)  评论(0编辑  收藏  举报
浏览器标题切换
浏览器标题切换end