RedHat 服务器安装NGINX

参照官方文档:nginx: Linux packages

按顺序操作:

安装前提:

sudo yum install yum-utils

 设置yum仓库:

sudo 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
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:

sudo yum install nginx

 查看版本:

nginx -v

编辑nginx配置:

vi /etc/nginx/conf.d/default.conf

启动nginx命令:

#启动
systemctl start nginx
#检查状态
systemctl status nginx
#设置自启动
systemctl enable nginx

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