本文最后更新于703 天前,其中的信息可能已经过时,如有错误请发送邮件到3260245294@qq.com
先前准备
先wget nginx源码包
wget http://nginx.org/download/nginx-1.17.0.tar.gz
安装所需依赖
yum -y install gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
groupadd nginx ##创建用户组
useradd -g nginx nginx ##创建用户nginx并添加属组为nginx
tar -axv -f nginx-1.17.0.tar.gz && cd nginx-1.17.0 ##解压nginx并进入目录
./configure && make && make install ##进行编译
创建服务文件
vim /usr/lib/systemd/system ##进入系统服务文件夹
vim /usr/lib/systemd/system/nginx.service ##创建nginx服务文件
[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=/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=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
重启主机测试
添加Nginx系统服务完成
Can you be more specific about the content of your article? After reading it, I still have some doubts. Hope you can help me.