nginx安装

风格不统一 提交于 2020-01-21 02:40:24

系统环境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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!