编辑安装NGINX
- 安装必要的依赖包
- 创建nginx用户
- 解压
nginx-1.18.0.tar.gz
- 编译安装
- 创建自启动脚本
[root@centos8 ~]#yum install gcc gcc-c++ pcre pcre-devel openssl-devel zlib zlib-devel make lrzsz vim tree wget lsof
[root@centos8 ~]#useradd nginx
[root@centos8 ~]#tar xf nginx-1.18.0.tar.gz
[root@centos8 ~]#cd nginx-1.18.0
[root@centos8 ~]#./configure --prefix=/apps/nginx \ #程序路径
--user=nginx \
--group=nginx \
--with-http_ssl_module \ #启用ssl模块
--with-http_v2_module \
--with-http_realip_module \
--with-stream \ #开启proxy
--with-stream_ssl_module \
--with-stream_realip_module
[root@centos8 ~]#make && make install
[root@centos8 ~]#cat /usr/lib/systemd/system/nginx.service
[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/apps/nginx/logs/nginx.pid
# Nginx will fail to start if /run/nginx.pid already exists but has the wrong
# SELinux context. This might happen when running `nginx -t` from the cmdline.
# https://bugzilla.redhat.com/show_bug.cgi?id=1268621
ExecStartPre=/usr/bin/rm -f /apps/nginx/logs/nginx.pid
ExecStartPre=/apps/nginx/sbin/nginx -t
ExecStart=/apps/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true
[Install]
WantedBy=multi-user.target
[root@centos8 ~]#systemctl daemon-reload
[root@centos8 ~]#systemctl enable --now nginx