赞
踩
metis-5.1.0-12.el7.x86_64.rpm
软件名:metis
软件版本:5.1.0-12
适用的系统类型:el7,这个表示在centos7可用
适用的cpu架构:x86_64
后缀:rpm
rpm [选项] [操作] [软件包]
选项:
选项 | 作用 |
---|---|
-i, --install | 安装软件包 |
-U, --upgrade | 升级软件包 |
-e,–erase | 卸载软件包 |
-q,–qurey | 查询已安装的软件包 |
-V,–verbose | 验证软件包 |
-h,–hash | 显示安装进度 |
-ivh | 最常用的安装选项 |
–force | 强制安装 |
–nodeps:忽略依赖关系 | 安装成功,但未必能够成功运行, |
–replacepkgs:覆盖安装 | 如果要安装软件包,但是包中的部分文件已经存在,那么在正常安装时会报"某个文件已经存在"的错误,从而导致软件无法安装。使用replacefiles选项可以忽略这个报错而覆盖安装。 |
–prefix:指定安装路径 | –prefix 安装路径 包名.rpm |
安装软件的时候可以先检查一下是否安装
[root@localhost ~]# rpm -q 软件名
第一步:将光盘挂载到虚拟机
第二步:挂载光盘
1)找一个空目录【一般找/mnt 或者 /media】
ls /mnt
此时这个目录是空的
2)将/dev/cdrom 挂载到 /mnt
mount /dev/cdrom /mnt
第三步:查看rpm包
ls /mnt/Packages/
这里面都是软件包这里只展示了十条
第四步:安装软件(tree)
[root@localhost ~]# cd /mnt/Packages/ #必须要到这里来否则就会提示找不到文件
[root@localhost Packages]# rpm -ivh tree-1.6.0-10.el7.x86_64.rpm
第五步:检查是否安装成功
[root@localhost Packages]# rpm -q zsh
tree-1.6.0-10.el7.x86_64
补充:
[root@localhost ~]# rpm -ql tree
/usr/bin/tree
/usr/share/doc/tree-1.6.0
/usr/share/doc/tree-1.6.0/LICENSE
/usr/share/doc/tree-1.6.0/README
/usr/share/man/man1/tree.1.gz
[root@localhost Packages]# rpm -qf /etc/passwd
setup-2.8.71-11.el7.noarch
[root@localhost Packages]# rpm -e tree
[root@localhost Packages]# rpm -q tree
package tree is not installed
例如:安装gcc
这个依赖关系就是,你如果想要下载A软件就必须要先下载B软件,要是想要下载B软件就先要下载C软件......
A --> B ---> C ----> D ------> E
如此以来如果被依赖的软件包很多很多,这样的安装相对来说就过于繁琐,于是我们就迎来了依赖软件包的克星——就是他:yum安装
第一种:自己创建yum仓库(新手不建议)
第二种:使用现有的yum仓库【本地/远程】
创建本地yum源有两种方法:
第一步:挂载光盘
mkdir /test/testyum -p
mount /dev/cdrom /test/testyum/
检查挂载点
ls /test/testyum/
第二步:修改yum的配置文件,指向我们创建的yum源:/test/testyum/
yum的配置文件包括主配置文件和子配置文件
主配置文件:/etc/yum.conf
子配置文件:/etc/yum.repos.d下,配置文件名称无所谓,但是后缀必须是.repo
我们现在要用的是子配置文件
1)切换路径
[root@localhost ~]# cd /etc/yum.repos.d/
2)备份/删除原来的配置文件
[root@localhost yum.repos.d]# mkdir bak
[root@localhost yum.repos.d]# mv *.repo bak
3)新建一个配置文件,指向我们的yum仓库
[root@localhost yum.repos.d]# vi local.repo
[myrepo] # 指定yum仓库的id,这行不能有空格
name=my repo # 指定yum仓库的名称,可以随便写
enabled=1 # 指定yum仓库是否激活,0表示不激活;1表示激活可用
gpgcheck=0 # 指定是否检查rpm包的来源合法性,0表示不检查;1表示检查,如果要检查的话
baseurl=file:///test/testyum/ # 指定yum仓库的位置
第三步:检查配置是否成功
[root@localhost yum.repos.d]# yum clean all #清除之前yum源的缓存
[root@localhost yum.repos.d]# yum repolist #重新加载配置的yum源
#没有报错就是配置成功
第四步:安装软件
[root@localhost yum.repos.d]# yum install gcc
#期间会自动解决依赖关系并询问是否安装以来输入“y”确定安装
补充:
网络源
- 阿里:https://mirrors.aliyun.com/
- 华为:https://mirrors.huaweicloud.com/
- 网易:https://mirrors.163.com/
- 清华:https://mirrors.tuna.tsinghua.edu.cn/
- 中科大:https://mirrors.ustc.edu.cn/
清华centos7网络源地址:
https://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/os/x86_64/
因为使用网络源下软件本质上是访问这个网页之后再下载,所以必须保证虚拟接可以访问外网
第一步:配置linux网络
1)给虚拟机添加新网卡
2)重启网络
systemctl restart network
3)检查新网卡是否有IP
ip addr
4)检查网络是否正常
ping www.qq.com
第二步:配置清华centos源文件
1)创建yum源配置文件
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# vim qinghua-centos.repo
[qh01centos]
name=qh centos
enabled=1
gpgcheck=0
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/os/x86_64/
2)检查是否成功
[root@localhost yum.repos.d]# yum clean all
[root@localhost yum.repos.d]# yum repolist
什么是epel?
第一步:创建yum源配置文件
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# vim qinghua-epel.repo
[qinghuaepel]
name=qinghua epel
enabled=1
gpgcheck=0
baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7Server/x86_64/
第二步:检查是否成功
[root@localhost yum.repos.d]# yum clean all
[root@localhost yum.repos.d]# yum repolist
安装软件
卸载软件
清除缓存
生成缓存
清除缓存
yum clean all
生成缓存
yum repoilist
安装软件
yum install 软件名1 软件名2 软件名3 ....
卸载软件
yum remove 软件名1 软件名2 软件名3 ....
tar -zxvf software.tar.gz
第一步:获取源代码包:
安装组件:lrzsz
yum install lrzsz -y
第二步:解压源代码包
[root@localhost ~]# tar xvf nginx-1.22.1.tar.gz
# 会得到一个压缩吧同名目录 nginx-1.22.1
第三步:配置编译参数:
1)进入解压目录
[root@localhost ~]# cd nginx-1.22.1
2)安装依赖
[root@localhost ~]# yum install gcc gcc-c++ pcre-devel zlib-devel openssl-devel
ncurses-devel -y
3)执行./configure
[root@localhost nginx-1.22.1]# ./configure --prefix=/usr/local/nginx
备注:日常生产环境使用nginx,编译模块按照nginx官方yum安装的模块,基本能满足95%以上的生产需求。yum安装模块如下,可自行参考:
# 生产环境使用
./configure --prefix=/opt/xxx/xxx --user=zdsoft --group=zdsoft --with-compat --with-debug --with-file-aio --with-google_perftools_module --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_degradation_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_mp4_module --with-http_perl_module=dynamic --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_xslt_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-stream_ssl_preread_module --with-threads --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'
第四步: 编译
需要在解压目录去执行,否则就会报错。
[root@localhost nginx-1.22.1]# make
#没有报错代表安装完成。
make执行完成后生成的中间件文件,都会放在objs/src目录下面
[root@localhost src]# ll
总用量 8
drwxr-xr-x 2 root root 4096 10月 18 17:15 core
drwxr-xr-x 3 root root 191 10月 18 17:15 event
drwxr-xr-x 4 root root 4096 10月 18 17:15 http
drwxr-xr-x 2 root root 6 10月 18 16:37 mail
drwxr-xr-x 2 root root 6 10月 18 16:37 misc
drwxr-xr-x 4 root root 31 10月 18 16:37 os
drwxr-xr-x 2 root root 6 10月 18 16:37 stream
[root@localhost src]# pwd
/opt/nginx-1.22.1/objs/src
[root@localhost src]#
第五步:安装
[root@localhost nginx-1.22.1]# make install
#执行安装命令,第一次安装可以执行,如果是升级,谨慎执行。
安装完成,安装目录为:/usr/local/nginx
nginx -v #查看nginx版本
nginx -V #查看nginx编译参数,如果没有额外的参数,只会显示configure arguments: --prefix=/home/zdsoft/nginx
#这情况下,代表是默认安装,可以查看源码目录auto/options 文件。默认安装了哪些模块,哪些没有安装。
第六步:nginx进程启动
这时候/usr/local/nginx/sbin里面有个可执行程序 nginx
[root@localhost nginx-1.22.1]# /usr/local/nginx/sbin/nginx
第七步:测试nginx
来到物理机的浏览器输入虚拟机的IP地址来看看是否成功启动
思考:
否
rpm或者yum,只能查看/控制rpm包安装的软件
如果使用了–prefix这个命令,那就把你指定的文件给删除了就行了。
今天我们聊了linux软件管理这个话题,分别是三个不同的命名不同的方法,各个都有其独特的特点,我们需要熟记并掌握这三种安装的过程,并保证出错之后可以有效的解决。以上就是今天的内容了,希望小伙伴们有什么不懂的点留在评论区,或者博主有什么写错了的东西都欢迎来各个学霸大佬来指出。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。