美文网首页
nginx编译安装

nginx编译安装

作者: JepWei | 来源:发表于2022-07-05 07:42 被阅读0次

1.安装依赖(离线环境自行准备)

yum -y install pcre-devel zlib-devel gcc gcc-c++ make

2.创建用户并上传源码包编译

useradd -M -s /sbin/nologin nginx
cd /opt
tar zxvf nginx-1.12.0.tar.gz -C /opt/
cd nginx-1.12.0/
./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_stub_status_module

make && make install

ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/nginx

#配置systemctl启动方式
vim /lib/systemd/system/nginx.service
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStart=/usr/local/nginx/sbin/nginx
ExecrReload=/bin/kill -s HUP $MAINPID
ExecrStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
 


chmod 754 /lib/systemd/system/nginx.service 
systemctl start nginx.service



相关文章

网友评论

      本文标题:nginx编译安装

      本文链接:https://www.haomeiwen.com/subject/prllbrtx.html