系统环境CentOS Linux release 7.7.1908 (Core)
安装make
yum -y install gcc automake autoconf libtool make
安装g++
yum install gcc gcc-c++
安装nginx
cd /usr/local/src wget http://nginx.org/download/nginx-1.17.3.tar.gz tar -zxvf nginx-1.17.3.tar.gz cd nginx-1.17.3 ./configure make make install
nginx 自启动
1、目录/usr/lib/systemd/system增加文件nginx.service
2、文件内容
[Unit]
Description=nginx service
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
3、开机启动
systemctl enable nginx.service
4、启动服务
(启动nginx服务)
systemctl start nginx.service
(停止nginx服务)
systemctl stop nginx.service
(设置开机自启动)
systemctl enable nginx.service
(停止开机自启动)
systemctl disable nginx.service
(查看服务当前状态)
systemctl status nginx.service
(重新启动服务)
systemctl restart nginx.service
(查看所有已启动的服务)
systemctl list-units --type=service