2018-1-9 5周2次課 yum、源碼包
系統自帶的源是國外網站,可能不好使用,比如網速較慢等,這樣可以更換國內的源
·如果自建了yum源,那麽先恢復默認的源
[root@localhost yum.repos.d]# cd .. [root@localhost etc]# cp yum.repos.d.bak/ yum.repos.d cp: 略過目錄"yum.repos.d.bak/" [root@localhost etc]# cp -r yum.repos.d.bak/ yum.repos.d [root@localhost etc]# ls yum.repos.d 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 CentOS-Base.repo ##刪除基礎源 rm:是否刪除普通文件 "CentOS-Base.repo"?y [root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo -bash: wget: 未找到命令 ##未安裝wget,但是源已刪除 [root@localhost yum.repos.d]# curl -0 http://mirrors.163.com/.help/CentOS7-Base-163.repo # CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-$releasever - Base - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-$releasever - Updates - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus - 163.com baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 [root@localhost yum.repos.d]# vim CentOS7-Base-163.repo ##將數據復制進新建的源 此處省略 [root@localhost yum.repos.d]# yum list ##查看可用的包 [root@localhost yum.repos.d]# yum install wget
[root@localhost yum.repos.d]# yum repolist all
已經更換了163的源
7.7 yum下載rpm包
·安裝擴展源epel
[root@localhost ~]# cd /etc/yum.repos.d [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 ##擴展源 過程省略 [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 list ##會有更多的包出現,以epel結尾
[root@localhost yum.repos.d]# yum list |grep epel ##只選擇epel的包
(圖中只取部分)
·yum下載rpm包
先確認要下載的包是不是已經安裝過了
[root@localhost yum.repos.d]# yum install -y znc --downloadonly
[root@localhost yum.repos.d]# rpm -q znc 未安裝軟件包 znc [root@localhost yum.repos.d]# ls /var/cache/yum/x86_64/7/epel/packages/ ##包默認下載位置 znc-1.6.5-1.el7.x86_64.rpm
·指定包的下載目錄:
[root@localhost yum.repos.d]# yum install -y zmap --downloadonly --downloaddir=絕對路徑
(包和依賴包都會下載到指定目錄下)
·已經安裝過的包下載到指定位置:yum install -y 包名 --downloadonly --downloaddir=絕對路徑
如果包已經安裝過,那麽下載時會提示不做處理
[root@localhost yum.repos.d]# yum install -y vim-enhanced --downloadonly --downloaddir=/tmp/ 已加載插件:fastestmirror Loading mirror speeds from cached hostfile * epel: mirrors.tongji.edu.cn 軟件包 2:vim-enhanced-7.4.160-2.el7.x86_64 已安裝並且是最新版本 無須任何處理
這時,可以用yum reinstall
[root@localhost yum.repos.d]# yum reinstall -y vim-enhanced --downloadonly --downloaddir=/tmp/
7.8 、7.9 源碼包安裝
★★★源碼包放置的位置 /usr/local/src
[root@localhost /]# cd /usr/local/src [root@localhost src]# wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.32.tar.gz --2018-01-06 22:16:04-- 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 請求,正在等待回應... 404 Not Found 2018-01-06 22:16:04 錯誤 404:Not Found。 ##地址不正確,去找正確地址 [root@localhost src]# wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.34.tar.gz --2018-01-06 22:17:04-- http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.34.tar.gz 正在解析主機 mirrors.cnnic.cn (mirrors.cnnic.cn)... 101.6.6.178, 2402:f000:1:416:101:6:6:178 正在連接 mirrors.cnnic.cn (mirrors.cnnic.cn)|101.6.6.178|:80... 已連接。 已發出 HTTP 請求,正在等待回應... 200 OK 長度:7684419 (7.3M) [application/octet-stream] 正在保存至: “httpd-2.2.34.tar.gz” 100%[==========================================================================>] 7,684,419 2.10MB/s 用時 3.5s 2018-01-06 22:17:08 (2.10 MB/s) - 已保存 “httpd-2.2.34.tar.gz” [7684419/7684419]) [root@localhost src]# tar zxvf httpd-2.2.34.tar.gz 文件過多,不詳細展示 [root@localhost src]# cd httpd-2.2.34 [root@localhost httpd-2.2.34]# 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
·安裝源碼包:
1.檢測:/configure
./configure
--prefix 指定安裝位置 (源碼包安裝完成後,所有目錄會統一在一個文件夾中)
[root@localhost httpd-2.2.34]# ./configure --prefix=/usr/local/apache2
那麽先去安裝gcc:yum install -y gcc
安裝完成後,再次執行./configure --prefix=/usr/local/apache2
等待完成……
[root@localhost httpd-2.2.34]# echo $? 0
沒有問題
2.編譯:make
[root@localhost httpd-2.2.34]# make 等待完成...... [root@localhost httpd-2.2.34]# echo $? 0
沒有問題
3.安裝:make install
[root@localhost httpd-2.2.34]# make install 等待完成…… [root@localhost httpd-2.2.34]# echo $? 0 [root@localhost httpd-2.2.34]# ls /usr/local/apache2/ bin build cgi-bin conf error htdocs icons include lib logs man manual modules
·卸載就是刪除安裝的文件 (指定安裝目錄的)
☆試著去安裝php的包http://cn2.php.net/distributions/php-5.6.30.tar.bz2
下載到 /usr/local/src 下,解壓後,進入到/usr/local/src/php-5.6.30目錄下
./configure --prefix=/usr/local/php5 檢查並指定安裝目錄為/usr/local/php5
出現問題,關於的錯誤,找不到makefile,無法make
查了下之前信息,libxml2報錯
運行命令yum provides ’/*/libxml2 ' 查到了libxml2-devel
yum install -y libxml2-devel完成安裝
再次./configure --prefix=/usr/local/php5,這次成功了
之後make
完成安裝
[root@localhost php5]# ls
bin etc include lib php
2018-1-9 5周2次課 yum、源碼包