美文网首页
CentOs7下安装nginx并设置开机启动

CentOs7下安装nginx并设置开机启动

作者: 睡不醒的邢老吉 | 来源:发表于2019-03-13 15:51 被阅读0次

1安装nginx

yum install nginx

2.设置开机启动

systemctl enable nginx.service

3.其他命令

启动nginx服务

systemctl start nginx.service

设置开机自启动

systemctl enable nginx.service

停止开机自启动

systemctl disable nginx.service

查看服务当前状态

systemctl status nginx.service

重新启动服务

systemctl restart nginx.service

查看所有已启动的服务

systemctl list-units --type=service

对于最新的cent7.6

官网地址:http://nginx.org/en/linux_packages.html#RHEL-CentOS

需先安装依赖:sudo yum install -y yum-utils

安装开始:

第一步:

找到系统目录,并创建repo文件:vi /etc/yum.repos.d/nginx.repo,内容如下:

[nginx-stable]

name=nginx stable repo

baseurl=http://nginx.org/packages/centos/$releasever/$basearch/

gpgcheck=1

enabled=1

gpgkey=https://nginx.org/keys/nginx_signing.key

第二步:

运行安装脚本:sudo yum install -y nginx

第三步:

检查安装版本:nginx -v

相关文章

网友评论

      本文标题:CentOs7下安装nginx并设置开机启动

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