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 $?
只要將安裝軟件時建立的文件、目錄刪除便可!安裝時指定安裝文件在一個目錄,卸載時就直接將該目錄刪除就能徹底卸載掉軟件。