码迷,mamicode.com
首页 > 其他好文 > 详细

centOS 7 安装nginx服务

时间:2019-10-04 23:17:19      阅读:210      评论:0      收藏:0      [点我收藏+]

标签:start   private   div   自启动   ecs   art   pen   star   bsp   

一、安装相关依赖

yum install gcc-c++

yum install -y pcre pcre-devel

yum install -y zlib zlib-devel

yum install -y openssl openssl-devel

二、到官网下载安装包进行安装

到官网下载tar.gz安装包,地址:https://nginx.org/en/download.html

tar -zxvf nginx-1.16.1.tar.gz

cd nginx-1.16.1.tar.gz

./configure

make

make install

whereis nginx

三、设置开机自启动

在/usr/lib/systemd/system目录下创建nginx.service文件,内容如下:

[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

加入开机自启动:

systemctl enable nginx

取消开机自启动:

systemctl disable nginx

四、服务操作命令

启动nginx服务

# systemctl start nginx.service          

停止服务

# systemctl stop nginx.service          

重新启动服务

# systemctl restart nginx.service       

查看服务当前状态

# systemctl status nginx.service 

 

 

 

 

 

 

centOS 7 安装nginx服务

标签:start   private   div   自启动   ecs   art   pen   star   bsp   

原文地址:https://www.cnblogs.com/101key/p/11623456.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!