目录
1、准备安装环境
bash
yum insatall -y make gcc gcc-c++ pcre-devel
#pcre-devel -- pcre库
#安装openssl-devel
yum install -y openssl-devel
2、获取tar包:
3、解压创建软链接
bash
tar -xf nginx-1.22.0.tar.gz -C /usr/local/
ln -s /usr/local/nginx-1.22.0/ /usr/local/nginx
4、创建用户和组
bash
groupadd -r nginx
useradd nginx -u 996 -r -g 996 -c "nginx user"
5、执行安装
bash
./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
make && make
6、创建服务脚本
bash
#vim /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/run/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=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
#systemctl daemon-reload