1、先下载前置包
代码语言:javascript复制yum install yum-utils
报错的话看最下边
2、进入文件配置信息
代码语言:javascript复制cd /etc/yum.repos.d/
vim nginx.repo
输入以下信息
代码语言:javascript复制[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
[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
3、直接下载安装nginx
代码语言:javascript复制yum install nginx
4、安装完后,查看启动nginx
代码语言:javascript复制rpm -qa | grep nginx
代码语言:javascript复制systemctl start nginx
5、加入开机启动
代码语言:javascript复制systemctl enable nginx
6、查看nginx的状态
代码语言:javascript复制systemctl status nginx
7、nginx服务的默认配置文件在vim /etc/nginx/conf.d/default.conf,打开可看到,默认端口为80,项目部署目录为/usr/share/nginx/html/
报错收集
yum install yum-utils报错
代码语言:javascript复制Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
Package yum-utils-1.1.31-54.el7_8.noarch already installed and latest version
Nothing to do
解决步骤:
1、修改配置文件
代码语言:javascript复制vi /etc/yum/pluginconf.d/fastestmirror.conf
代码语言:javascript复制[main]
enabled=0 //把1改为0
verbose=0
socket_timeout=3
hostfilepath=/var/cache/yum/timedhosts.txt
maxhostfileage=10
maxthreads=15
2、修改另一个配置文件
代码语言:javascript复制vi /etc/yum.conf
代码语言:javascript复制[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1 #将plugins的值修改为0
installonly_limit=5