Nginx入门与精通

centos7安装nginx

官方文档:http://nginx.org/en/linux_packages.html#RHEL-CentOS

安装方法一:yum配置安装

安装先决条件:

sudo yum install yum-utils

/etc/yum.repos.d/nginx.repo增加nginx的yum源

[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
module_hotfixes=true

[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

看一下是否成功加载了这个安装源
Nginx入门与精通_第1张图片

通过yum安装nginx
Nginx入门与精通_第2张图片

安装好后,直接用systemctl启动nginx服务

systemctl enable nginx  #设置nginx为开机启动

systemctl start nginx  #启动nginx服务

你可能感兴趣的:(linux,nginx)