NGINX的安装部署
一、版本区别
常用版本分为四大阵营:
- Nginx开源版:http://nginx.org/
- Nginx Plus商业版:https://www.nginx.com
- openresty:http://openresty.org/cn/
- Tengine:http://tengine.taobao.org
二、源码编译安装
$ 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
*************** 当你发现自己的才华撑不起野心时,就请安静下来学习吧!***************