一.RPM软件包
通过镜像(光盘)安装软件
挂载
[root@localhost tmp]# mount -t iso9660 /dev/cdrom /mnt
卸载
[root@localhost ~]# umount /mnt 或者 umount /dev/cdrom
强制卸载
[root@localhost mnt]# umount -l /mnt/
[root@localhost Packages]# cd /mnt/Packages/
[root@localhost Packages]# rpm -ivh tree-1.6.0-10.el7.x86_64.rpm -i install -v 显示过程 -h 显示%
[root@localhost Packages]# rpm -q tree -q query 检索
[root@localhost Packages]# rpm -ql tree -l list 列出文件的所有安装位置
[root@localhost Packages]# rpm -qi tree -i infomation 信息
[root@localhost Packages]# rpm -qc tree -c configuration 配置文件
[root@localhost Packages]# rpm -qd tree -d document 文档
[root@localhost Packages]# rpm -qf /etc/man_db.conf -f file 通过文件查询对应的软件安包
[root@localhost Packages]# rpm -qf `which tree` 通过命令查询软件包
[root@localhost Packages]# rpm -e tree 卸载软件
未安装软件包查询
[root@localhost Packages]# rpm -qpi httpd-2.4.6-90.el7.centos.x86_64.rpm -p 包
[root@localhost Packages]# rpm -qpl httpd-2.4.6-90.el7.centos.x86_64.rpm
依赖关系
安装
[root@localhost Packages]# rpm -ivh httpd-2.4.6-90.el7.centos.x86_64.rpm
错误:依赖检测失败:
/etc/mime.types 被 httpd-2.4.6-90.el7.centos.x86_64 需要
httpd-tools = 2.4.6-90.el7.centos 被 httpd-2.4.6-90.el7.centos.x86_64 需要
libapr-1.so.0()(64bit) 被 httpd-2.4.6-90.el7.centos.x86_64 需要
libaprutil-1.so.0()(64bit) 被 httpd-2.4.6-90.el7.centos.x86_64 需要
[root@localhost Packages]# rpm -ivh apr-1.4.8-5.el7.x86_64.rpm
[root@localhost Packages]# rpm -ivh apr-util-1.5.2-6.el7.x86_64.rpm
[root@localhost Packages]# rpm -ivh httpd-tools-2.4.6-90.el7.centos.x86_64.rpm
[root@localhost Packages]# rpm -ivh mailcap-2.1.41-2.el7.noarch.rpm
[root@localhost Packages]# rpm -ivh httpd-2.4.6-90.el7.centos.x86_64.rpm
卸载
[root@localhost Packages]# rpm -e apr
错误:依赖检测失败:
libapr-1.so.0()(64bit) 被 (已安裝) apr-util-1.5.2-6.el7.x86_64 需要
libapr-1.so.0()(64bit) 被 (已安裝) httpd-tools-2.4.6-90.el7.centos.x86_64 需要
libapr-1.so.0()(64bit) 被 (已安裝) httpd-2.4.6-90.el7.centos.x86_64 需要
[root@localhost Packages]# rpm -e httpd
[root@localhost Packages]# rpm -e httpd-tools
[root@localhost Packages]# rpm -e apr-util
[root@localhost Packages]# rpm -e apr
yum库(本地yum)
1.挂载镜像,提供安装源
mkdir /yum
[root@localhost tmp]# mount -t iso9660 /dev/cdrom /yum
2.配置yum库
[root@localhost Packages]# cd /etc/yum.repos.d/ #该目录下所有 .repo扩展名的文件
备份已有的yum配置文件
[root@localhost yum.repos.d]# mkdir /etc/yum.repos.d/old
[root@localhost yum.repos.d]# mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/old/
创建配置文件
[root@localhost yum.repos.d]# touch local.repo
[root@localhost yum.repos.d]# vim local.repo
[local_iso]
name=本地仓库
baseurl=file:///yum
gpgcheck=0
enabled=1
导入校验key
[root@localhost yum.repos.d]# rpm --import /yum/RPM-GPG-KEY-CentOS-7
[root@localhost yum.repos.d]# rpm --import /yum/RPM-GPG-KEY-CentOS-Testing-7
[root@localhost yum.repos.d]# vim local.repo
[local_iso]
name=本地仓库
baseurl=file:///yum
gpgcheck=1
enabled=1
测试
[root@localhost yum.repos.d]# yum makecache fast 建立yum缓存
[root@localhost ~]# yum list 列出所有的软件包
[root@localhost ~]# yum repolist 列出每个yum库的状态
[root@localhost ~]# yum search httpd 列出所有与httpd相关软件包
[root@localhost ~]# yum provides /etc/man_db.conf 列出文件对应的软件包
[root@localhost ~]# yum history 查看yum库安装历史
[root@localhost ~]# yum install -y httpd 安装软件 -y 表示确认安装
[root@localhost ~]# yum reinstall httpd 重新安装(已安装软件)
[root@localhost ~]# yum remove -y httpd 卸载软件
[root@localhost ~]# yum info tree 查看包的信息
[root@localhost ~]# yum clean all 清除缓存
[root@localhost ~]# yum grouplist 查看分组
[root@localhost ~]# yum groupinstall "带 GUI 的服务器"
手动建库
[root@localhost ~]# mkdir /mysql
[root@localhost ~]# tar -xvf mysql-5.7.34-1.el7.x86_64.rpm-bundle.tar -C /mysql 解压软件包
-C 指定解压位置
[root@localhost mysql]# yum install -y createrepo 安装 创建yum的命令
[root@localhost mysql]# createrepo /mysql/ #建立依赖关系
[root@localhost yum.repos.d]# vim mysql.repo
[mysql]
name=mysql server
baseurl=file:///mysql
gpgcheck=0
enabled=1
测试
yum install mysql-server
二.压缩打包
压缩 gzip bzip2
[root@localhost ~]# dd if=/dev/zero of=/root/data bs=50M count=4 创建指定大小的文件
/dev/zero 零发声器
/dev/null 黑洞文件
bs block size
数据块就是多个连续性的扇区(sector),扇区是文件存储的最小单位(每个512字节)。块(block)的大小,最常见的是4KB,也就是连续8个sector组成,存储文件数据和目录数据
[root@localhost ~]# du -sh /usr -s 总数 -h 最大单位
4.6G /usr
[root@localhost ~]# du -sh data
200M data
gzip压缩
[root@localhost ~]# gzip data
[root@localhost ~]# gunzip data.gz
bzip2压缩
[root@localhost ~]# bzip2 data
[root@localhost ~]# bunzip2 data.bz2
打包
[root@localhost ~]# tar -cvf boot.tar /boot -c create -v显示过程 -f file
[root@localhost ~]# tar -xvf boot.tar -x 解包
[root@localhost ~]# tar -tvf boot.tar -t 查询包内的文件
[root@localhost ~]# tar -rvf boot.tar /root/data 追加打包
[root@localhost ~]# tar -zcvf boot.tar.gz /boot/ -z gzip 打包并压缩
[root@localhost ~]# tar -zxvf boot.tar.gz 解压缩包
[root@localhost ~]# tar -ztvf boot.tar.gz 查看压缩包
[root@localhost ~]# tar -jcvf boot.tar.bz2 /boot/ -j bzip2
[root@localhost ~]# tar -jxvf boot.tar.bz2
[root@localhost ~]# tar -jtvf boot.tar.bz2
[root@localhost ~]# tar -jcvf /tmp/boot.tar.bz2 /boot/ 指定路径打包
[root@localhost ~]# tar -zxvf /root/boot.tar.gz -C /tmp/ 指定目录解压
tgz tbz2
三.源码包安装
[root@localhost ftp]# wget https://nginx.org/download/nginx-1.21.1.tar.gz -P /tmp/
[root@localhost ftp]# wget https://nginx.org/download/nginx-1.21.1.tar.gz
[root@localhost ftp]# tar -xvf nginx-1.21.1.tar.gz -C /usr/local/src/
[root@localhost nginx-1.21.1]# ./configure --prefix=/usr/local/nginx 编译前配置(Makefile)与检测(编译器/库)
[root@localhost nginx-1.21.1]# make 编译
[root@localhost nginx-1.21.1]# make install 编译安装
移除软件
[root@localhost nginx-1.21.1]# rm -rf /usr/local/nginx/
错误1:
解决
root@localhost nginx-1.21.1]# yum install gcc gcc-c++
错误2:
解决
[root@localhost nginx-1.21.1]# yum install -y pcre-devel
错误3:
解决:
[root@localhost nginx-1.21.1]# yum install -y zlib-devel