yum更換國內源,yum下載rpm包,源碼包安裝
阿新 • • 發佈:2018-04-20
yum更換國內源yum下載rpm包源yum更換國內源
-
刪除國外源CentOS-Base.repo
[root@localhost 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
[root@localhost yum.repos.d]# rm -f CentOS-Base.repo
[root@localhost yum.repos.d]#
-
添加國內源
- wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
- curl -O http://mirrors.163.com/.help/CentOS7-Base-163.repo
因為剛剛把yum源刪掉了,wget沒有安裝,無法yum安裝所以使用curl來進行添加。
[root@localhost yum.repos.d]# curl -O http://mirrors.163.com/.help/CentOS7-Base-163.repo % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1572 100 1572 0 0 7271 0 --:--:-- --:--:-- --:--:-- 7311 [root@localhost yum.repos.d]# ls CentOS7-Base-163.repo CentOS-CR.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Sources.repo CentOS-Vault.repo [root@localhost yum.repos.d]#
之後可以安裝一個rpm包試一下
[root@localhost yum.repos.d]# yum install -y wget 已加載插件:fastestmirror base | 3.6 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 Determining fastest mirrors 正在解決依賴關系 --> 正在檢查事務 ---> 軟件包 wget.x86_64.0.1.14-13.el7 將被 安裝 --> 解決依賴關系完成 依賴關系解決 ==================================================================================================================================================== Package 架構 版本 源 大小 ==================================================================================================================================================== 正在安裝: wget x86_64 1.14-13.el7 base 546 k 事務概要 ==================================================================================================================================================== 安裝 1 軟件包 總下載量:546 k 安裝大小:2.0 M Downloading packages: wget-1.14-13.el7.x86_64.rpm | 546 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction 正在安裝 : wget-1.14-13.el7.x86_64 1/1 驗證中 : wget-1.14-13.el7.x86_64 1/1 已安裝: wget.x86_64 0:1.14-13.el7 完畢! [root@localhost yum.repos.d]#
安裝擴展源epel
-
yum install -y epel-release
[root@localhost yum.repos.d]# ls
CentOS7-Base-163.repo CentOS-CR.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Sources.repo CentOS-Vault.repo
[root@localhost yum.repos.d]# yum install -y epel-release
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
正在解決依賴關系
--> 正在檢查事務
---> 軟件包 epel-release.noarch.0.7-9 將被 安裝
--> 解決依賴關系完成
完畢!
[root@localhost yum.repos.d]# ls
CentOS7-Base-163.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo epel-testing.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo epel.repo
[root@localhost yum.repos.d]#
多了兩個安裝源
yum下載rpm包
-
僅下載不安裝:[root@localhost yum.repos.d]# yum install zsh --downloadonly
-
下載位置在:/var/cache/yum/x86_64/7/倉庫名/packages/
[root@localhost yum.repos.d]# ls /var/cache/yum/x86_64/7/updates/packages/
zsh-5.0.2-25.el7_3.1.x86_64.rpm
-
指定下載目錄:-- downloadonly --downloaddir=/tmp/
[root@localhost yum.repos.d]# yum install zsh --downloadonly --downloaddir=/tmp/
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
* epel: mirrors.neusoft.edu.cn
正在解決依賴關系
--> 正在檢查事務
---> 軟件包 zsh.x86_64.0.5.0.2-25.el7_3.1 將被 安裝
--> 解決依賴關系完成
[root@localhost yum.repos.d]# ls /tmp/
1.txt
1.txt.gz
zsh-5.0.2-25.el7_3.1.x86_64.rpm
[root@localhost yum.repos.d]#
-
如果下載已經安裝過的rpm包會提示已經安裝,不會下載。除了卸載已經安裝的包重新下載外還有一個方法:yum reinstall
[root@localhost yum.repos.d]# yum install vim-enhanced --downloadonly --downloaddir=/tmp/
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
* epel: ftp.jaist.ac.jp
軟件包 2:vim-enhanced-7.4.160-1.el7_3.1.x86_64 已安裝並且是最新版本
無須任何處理
[root@localhost yum.repos.d]# yum reinstall vim-enhanced --downloadonly --downloaddir=/tmp/
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
* epel: mirrors.tuna.tsinghua.edu.cn
正在解決依賴關系
--> 正在檢查事務
---> 軟件包 vim-enhanced.x86_64.2.7.4.160-1.el7_3.1 將被 已重新安裝
--> 解決依賴關系完成
源碼包安裝
-
首先需要根據自己需求下載一個源碼包
約定:以後源碼包下載好後放到cd /usr/local/src/下
-
可以下載一個apache進行安裝實驗
[root@localhost yum.repos.d]# cd /usr/local/src/
[root@localhost src]# wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.32.tar.gz
--2017-08-29 22:37:00-- http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.32.tar.gz
正在解析主機 mirrors.cnnic.cn (mirrors.cnnic.cn)... 101.6.6.178, 2402:f000:1:416:101:6:6:177
正在連接 mirrors.cnnic.cn (mirrors.cnnic.cn)|101.6.6.178|:80... 已連接。
已發出 HTTP 請求,正在等待回應... 302 Found
位置:http://219.239.26.14/files/5162000009CC51A1/mirror.bit.edu.cn/apache//httpd/httpd-2.2.32.tar.gz [跟隨至新的 URL]
--2017-08-29 22:37:00-- http://219.239.26.14/files/5162000009CC51A1/mirror.bit.edu.cn/apache//httpd/httpd-2.2.32.tar.gz
正在連接 219.239.26.14:80... 已連接。
已發出 HTTP 請求,正在等待回應... 200 OK
長度:7684420 (7.3M) [application/octet-stream]
正在保存至: “httpd-2.2.32.tar.gz”
100%[==========================================================================================================>] 7,684,420 1.43MB/s 用時 5.1s
2017-08-29 22:37:06 (1.43 MB/s) - 已保存 “httpd-2.2.32.tar.gz” [7684420/7684420])
[root@localhost src]# ls
httpd-2.2.32.tar.gz
-
解壓包 :tar zxvf -zxvf httpd-2.2.32.tar.gz
-
查看源碼包
[root@localhost src]# ls
httpd-2.2.32 httpd-2.2.32.tar.gz
[root@localhost src]# cd httpd-2.2.32
[root@localhost httpd-2.2.32]# ls
ABOUT_APACHE BuildAll.dsp config.layout emacs-style httpd.spec LAYOUT LICENSE NOTICE README.platforms srclib
acinclude.m4 BuildBin.dsp configure httpd.dep include libhttpd.dep Makefile.in NWGNUmakefile README-win32.txt support
Apache.dsw buildconf configure.in httpd.dsp INSTALL libhttpd.dsp Makefile.win os ROADMAP test
build CHANGES docs httpd.mak InstallBin.dsp libhttpd.mak modules README server VERSIONING
[root@localhost httpd-2.2.32]#
-
查看源碼包INSTALL文件裏面有提示安裝方法
For complete installation documentation, see [ht]docs/manual/install.html or http://httpd.apache.org/docs/2.2/install.html $ ./configure --prefix=PREFIX $ make $ make install $ PREFIX/bin/apachectl start
-
安裝源碼包
[root@localhost httpd-2.2.32]# ./configure --prefix=/usr/local/apache2
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
Configuring Apache Portable Runtime library ...
checking for APR... reconfig
configuring package in srclib/apr now
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
Configuring APR library
Platform: x86_64-unknown-linux-gnu
checking for working mkdir -p... yes
APR Version: 1.5.2
checking for chosen layout... apr
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/usr/local/src/httpd-2.2.32/srclib/apr‘:
configure: error: no acceptable C compiler found in $PATH
See `config.log‘ for more details
configure failed for srclib/apr
[root@localhost httpd-2.2.32]#
這條命令執行是有報錯的。查看上一條命令執行的有沒有報錯輸入“echo $?”。輸出結果不是0說明有報錯
報錯說明gcc不存在,這樣的話yum安裝一下,yum install gcc
-
之後再進行安裝,看看還有沒有錯,如果還有錯就會停下來告訴哪裏有問題。
[root@localhost httpd-2.2.32]# echo $?
0
安裝完之後檢測echo $? 是0 ,說明沒有問題
-
之後該make了
大概等兩分鐘的樣子之後完成,然後查看有沒有錯誤
[root@localhost httpd-2.2.32]# echo $?
0
-
之後該make install
這條命令是安裝編譯好的文件
查看目錄下都安裝了什麽
[root@localhost httpd-2.2.32]# ls /usr/local/apache2/ bin build cgi-bin conf error htdocs icons include lib logs man manual modules [root@localhost httpd-2.2.32]#
- ### 卸載就是刪除安裝的文件
- ### 下載源碼包一定要註意安全,去官方或者可信任站點下載
# 擴展
1. 配置yum源優先級 http://ask.apelearn.com/question/7168
2. 把源碼包打包成rpm包 http://www.linuxidc.com/Linux/2012-09/70096.htm
yum更換國內源,yum下載rpm包,源碼包安裝