系统相关
首页 > 系统相关> > day23 rpm与yum安装nginx

day23 rpm与yum安装nginx

作者:互联网

rpm命令安装nginx

安装nginx步骤

rpm -ivh nginx-1.18.0-1.el7.ngx.x86_64.rpm 通过nginx下载包来安装

​ -i 是install安装的简写、

​ -v 显示详细安装过程信息

​ -h 显示安装的进度条

rpm -qc nginx 查询nginx安装位置信息

​ -q 是query 查询的意思

​ -c configfiles 配置文件意思,列出所有配置文件

记住关键文件

​ /etc/nginx/conf.d/default.conf #主配置文件

​ /etc/nginx/nginx.conf #子配置文件

rpm -ql nginx nginx在你系统所有的操作信息都查询出来

​ -q 是query的查询

​ -l 是list列表意思,即列出软件包中的文件

记住关键文件

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

/etc/nginx/nginx.conf

/etc/sysconfig/nginx

/usr/sbin/nginx #执行命令

/usr/share/nginx/html #代码目录自己写的网页

/var/log/nginx #日志目录

启动服务——了解

systemctl start nginx #启动nginx

iptables -F #关闭防火墙

打开谷歌浏览器 输入ip地址10.0.0.100

发现显示不出内容

可以执行以下内容,刷新浏览器内容即可

[root@centos7-100 ~]# systemctl start nginx 
[root@centos7-100 ~]# iptables -F
[root@centos7-100 ~]# echo zhaocheng >/usr/share/nginx/html/index.html

安装完检查:

浏览器输入:10.0.0.100

卸载:

rpm -e nginx 卸载nginx

rpm -evh nginx 详细显示卸载过程

yum命令安装nginx

yum安装优缺点:

1.yum 安装可以从仓库下载常用软件,不需要知道准确的软件包全称

2.yum安装可以自动解决依赖问题

3.必须要联网(外网)

yum源概念:

1.基础base源和拓展epel源

2.第三方源,nginx,zabbix

3.yum源文件是以*.repo结尾,放在/etc/yum.repos.d/*.repo

常用yum源地址

http://mirrors.aliyun.com/repo/
https://mirrors.tuna.tsinghua.edu.cn/
https://mirrors.tuna.tsinghua.edu.cn/help/centos/
https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/

yum常用命令:

1.进入yum源目录

cd /etc/yum.repos.d/ #cd 进入这个目录

查看base与epel源

[root@centos7-100 ~]# cd /etc/yum.repos.d/
[root@centos7-100 yum.repos.d]# ls
CentOS-Base.repo  CentOS-CR.repo  CentOS-Debuginfo.repo  CentOS-fasttrack.repo  CentOS-Media.repo  CentOS-Sources.repo  CentOS-Vault.repo  CentOS-x86_64-kernel.repo
[root@centos7-100 yum.repos.d]# vim CentOS-Base.repo

联网手动更新yum缓存

yum makecache fast

下载阿里源并指定文件名保存

wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

wget -O epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

在这个CentOS-Base.repo文件找到查找这个aliyuncs关键词,d是删除这个关键词的全部行

sed -i '/aliyuncs/d' CentOS-Base.repo 用vim也可以删除但是很麻烦,可以用这个命令一步解决

2.更新yum缓存

yum makecache fast #更新yum缓存相当于更新菜品一样

yum常用命令

yum search nginx #查看当前目录仓库有nginx的包

yum list |grep "nginx" #查询软件列表包含nginx关键字的软件

yum install nginx -y #yum安装nginx -y不用手动确认

yum provides command #列出包含这个命令的软件包名称command 是命令

1.执行该命令

[root@centos7-100 ~]# pstree
-bash: pstree: 未找到命令

2.yum provides pstree

[root@centos7-100 ~]# yum provides pstree
已加载插件:fastestmirror
Repository epel is listed more than once in the configuration
Repository epel-debuginfo is listed more than once in the configuration
Repository epel-source is listed more than once in the configuration
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
epel/x86_64/filelists_db                                                                                                                                                |  12 MB  00:00:02     
nginx-stable/7/x86_64/filelists_db                                                                                                                                      |  90 kB  00:00:00     
psmisc-22.20-17.el7.x86_64 : Utilities for managing processes on your system
源    :base
匹配来源:
文件名    :/usr/bin/pstree

3.按照含有pstree命令的软件

[root@centos7-100 ~]# yum install psmisc-22.20-17.el7.x86_64 -y
已加载插件:fastestmirror
Repository epel is listed more than once in the configuration
Repository epel-debuginfo is listed more than once in the configuration
Repository epel-source is listed more than once in the configuration
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 psmisc.x86_64.0.22.20-17.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

===============================================================================================================================================================================================
 Package                                      架构                                         版本                                               源                                          大小
===============================================================================================================================================================================================
正在安装:
 psmisc                                       x86_64                                       22.20-17.el7                                       base                                       141 k

事务概要
===============================================================================================================================================================================================
安装  1 软件包

总下载量:141 k
安装大小:475 k
Downloading packages:
psmisc-22.20-17.el7.x86_64.rpm                                                                                                                                          | 141 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : psmisc-22.20-17.el7.x86_64                                                                                                                                                 1/1 
  验证中      : psmisc-22.20-17.el7.x86_64                                                                                                                                                 1/1 

已安装:
  psmisc.x86_64 0:22.20-17.el7                                                                                                                                                                 

完毕!

标签:x86,CentOS,mirrors,day23,repo,nginx,yum,rpm
来源: https://www.cnblogs.com/zhaocheng690/p/15477090.html