10月10日任务apache
7.6 yum更换国内源centos
7.7 yum下载rpm包缓存
7.8/7.9 源码包安装网络
163仓库源:http://mirrors.163.com/.help/CentOS7-Base-163.repocurl
获取仓库源文件工具
[root@localhost ~]# cd /etc/yum.repos.d/
2. 获取网络仓库文件url
[root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo 或在无wget工具的前提下使用curl命令下载 [root@localhost yum.repos.d]# curl -O http://mirrors.163.com/.help/CentOS7-Base-163.repo
3. 备份原仓库Base文件spa
[root@localhost yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak
4. 清理缓存debug
[root@localhost yum.repos.d]# yum clean all
5. 查看仓库文件列表(生成新缓存)code
[root@localhost yum.repos.d]# yum list
查看当前缓存的仓库列表
[root@localhost yum.repos.d]# yum repolist all Failed to set locale, defaulting to C Loaded plugins: fastestmirror Determining fastest mirrors * base: mirrors.163.com * epel: mirrors.ustc.edu.cn * extras: mirrors.zju.edu.cn * updates: mirrors.aliyun.com repo id repo name status C7.0.1406-base/x86_64 CentOS-7.0.1406 - Base disabled C7.0.1406-centosplus/x86_64 CentOS-7.0.1406 - CentOSPlus disabled C7.0.1406-extras/x86_64 CentOS-7.0.1406 - Extras disabled C7.0.1406-fasttrack/x86_64 CentOS-7.0.1406 - CentOSPlus disabled C7.0.1406-updates/x86_64 CentOS-7.0.1406 - Updates disabled C7.1.1503-base/x86_64 CentOS-7.1.1503 - Base disabled C7.1.1503-centosplus/x86_64 CentOS-7.1.1503 - CentOSPlus disabled C7.1.1503-extras/x86_64 CentOS-7.1.1503 - Extras disabled C7.1.1503-fasttrack/x86_64 CentOS-7.1.1503 - CentOSPlus disabled C7.1.1503-updates/x86_64 CentOS-7.1.1503 - Updates disabled C7.2.1511-base/x86_64 CentOS-7.2.1511 - Base disabled C7.2.1511-centosplus/x86_64 CentOS-7.2.1511 - CentOSPlus disabled C7.2.1511-extras/x86_64 CentOS-7.2.1511 - Extras disabled C7.2.1511-fasttrack/x86_64 CentOS-7.2.1511 - CentOSPlus disabled C7.2.1511-updates/x86_64 CentOS-7.2.1511 - Updates disabled base/7/x86_64 CentOS-7 - Base enabled: 9591 base-debuginfo/x86_64 CentOS-7 - Debuginfo disabled base-source/7 CentOS-7 - Base Sources disabled c7-media CentOS-7 - Media disabled centosplus/7/x86_64 CentOS-7 - Plus disabled centosplus-source/7 CentOS-7 - Plus Sources disabled cr/7/x86_64 CentOS-7 - cr disabled dvd dvd enabled: 3831 epel/x86_64 Extra Packages for Enterprise enabled: 12045 epel-debuginfo/x86_64 Extra Packages for Enterprise disabled epel-source/x86_64 Extra Packages for Enterprise disabled epel-testing/x86_64 Extra Packages for Enterprise disabled epel-testing-debuginfo/x86_64 Extra Packages for Enterprise disabled epel-testing-source/x86_64 Extra Packages for Enterprise disabled extras/7/x86_64 CentOS-7 - Extras enabled: 280 extras-source/7 CentOS-7 - Extras Sources disabled fasttrack/7/x86_64 CentOS-7 - fasttrack disabled updates/7/x86_64 CentOS-7 - Updates enabled: 1059 updates-source/7 CentOS-7 - Updates Sources disabled repolist: 26806
yum install -y epel-release
# 默认的下载存放目录/var/cache/yum/x86_64/7/仓库名/packages [root@localhost ~]# yum install zsh --downloadonly Failed to set locale, defaulting to C Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.163.com * epel: mirrors.ustc.edu.cn * extras: mirrors.zju.edu.cn * updates: mirrors.aliyun.com Resolving Dependencies --> Running transaction check ---> Package zsh.x86_64 0:5.0.2-28.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ========================================================================== Package Arch Version Repository Size ========================================================================== Installing: zsh x86_64 5.0.2-28.el7 base 2.4 M Transaction Summary ========================================================================== Install 1 Package Total download size: 2.4 M Installed size: 5.6 M Background downloading packages, then exiting: zsh-5.0.2-28.el7.x86_64.rpm | 2.4 MB 00:05 exiting because "Download Only" specified [root@localhost ~]# ls -l /var/cache/yum/x86_64/7/base/packages/ total 2436 -rw-r--r--. 1 root root 2494444 Aug 11 04:24 zsh-5.0.2-28.el7.x86_64.rpm
2. 指定下载软件所存放的目录
# --downloaddir指定存放的目录 [root@localhost ~]# yum install zsh --downloadonly --downloaddir=/tmp/ Failed to set locale, defaulting to C Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.163.com * epel: mirrors.ustc.edu.cn * extras: mirrors.zju.edu.cn * updates: mirrors.aliyun.com Resolving Dependencies --> Running transaction check ---> Package zsh.x86_64 0:5.0.2-28.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ========================================================================== Package Arch Version Repository Size ========================================================================== Installing: zsh x86_64 5.0.2-28.el7 base 2.4 M Transaction Summary ========================================================================== Install 1 Package Total download size: 2.4 M Installed size: 5.6 M Background downloading packages, then exiting: exiting because "Download Only" specified [root@localhost ~]# ls -l /tmp/zsh-5.0.2-28.el7.x86_64.rpm -rw-r--r--. 1 root root 2494444 Aug 11 04:24 /tmp/zsh-5.0.2-28.el7.x86_64.rpm
3. 上述所下载的包是系统未安装的,要下载已安装软件的软件包,使用reinstall
# tree已安装,使用reinstall; # --downloaddir指定保存目录,本例中为当前目录; # 不指定,默认保存在/var/cache/yum/x86_64/7/仓库名/packages [root@localhost ~]# yum reinstall tree --downloadonly --downloaddir=./ Failed to set locale, defaulting to C Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.163.com * epel: mirrors.ustc.edu.cn * extras: mirrors.zju.edu.cn * updates: mirrors.aliyun.com Resolving Dependencies --> Running transaction check ---> Package tree.x86_64 0:1.6.0-10.el7 will be reinstalled --> Finished Dependency Resolution Dependencies Resolved ========================================================================== Package Arch Version Repository Size ========================================================================== Reinstalling: tree x86_64 1.6.0-10.el7 base 46 k Transaction Summary ========================================================================== Reinstall 1 Package Total download size: 46 k Installed size: 87 k Background downloading packages, then exiting: tree-1.6.0-10.el7.x86_64.rpm | 46 kB 00:01 exiting because "Download Only" specified
约定:源码包存放目录 /usr/local/src/
这里介绍的是通用的安装源码包的方式。有部分源码包使用的是cmake安装,较为复杂,这里就不介绍了。
例:安装apache
[root@localhost ~]# cd /usr/local/src/
2. 获取源码包并解压缩(无wget命令,yum安装便可)
[root@localhost src]# wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.34.tar.gz [root@localhost src]# tar -zxvf httpd-2.2.34.tar.gz
3. 进入软件安装包
[root@localhost src]# cd httpd-2.2.34/
4. 执行配置文件,检测安装环境,并生成部分安装文件
[root@localhost src]# ./configure --prefix=/usr/local/apache2
5. 编译
[root@localhost src]# make
6. 安装
[root@localhost src]# make install
判断上一个命令是否执行成功:0成功,其余不成功
echo $?
只要将安装软件时建立的文件、目录删除便可!安装时指定安装文件在一个目录,卸载时就直接将该目录删除就能彻底卸载掉软件。