centos7安装nginx1.18.0

本文参考自:https://www.cnblogs.com/opsprobe/p/10773582.html

      https://www.cnblogs.com/hhyf/p/11518919.html

nginx官网安装教程:http://nginx.org/en/linux_packages.html#RHEL-CentOS

一、安装

1.安装准备

sudo yum install yum-utils

2.增加源文件

vim /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

3.安装

sudo yum install nginx

4.查看安装版本

rpm -qa | grep nginx

 5.启动nginx

systemctl start nginx

若报错

 可能80端口被占用

netstat -apn|grep :80

 

 关闭80端口

service httpd stop

 再次重新启动,无报错则启动成功

6.查看启动状态

systemctl status nginx

 7.设置开机自启动

systemctl enable nginx

 到此安装成功!

 

posted on 2020-08-12 00:04  剑与心声  阅读(869)  评论(0编辑  收藏  举报