yum更換國內源、yum下載rpm包 、源碼包安裝

yum更換國內源

yum源默認從國外網站下載,速度相對較慢。能夠更換成內容源。html

步驟:ls /etc/yum.repos.d ,將CentOS-Base.repo移走或更名。linux

[root@glinux-01 ~]# ls /etc/yum.repos.d
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo

下載CentOS7-Base-163.repo文件,命令:wget http://mirrors.163.com/.help/CentOS7-Base-163.repoapache

該命令會將文件下載到當前目錄下,移動至/etc/yum.repos.d緩存

[root@glinux-01 ~]# ls
1.txt  anaconda-ks.cfg  bad  boduo.av  CentOS7-Base-163.repo  cuowu  test.sh  zhengque

注意:最好先安裝wget包,在移走CentOS-Base.repo。要不無法運行wget命令curl

也能夠用curl -O http://mirrors.163.com/.help/CentOS7-Base-163.repo下載CentOS7-Base-163.repo文件。網站

yum clean all 清除緩存。ui

安裝擴展源epel

有些源頗有用,可是自帶源沒有,須要安裝擴展源url

方法:spa

  • yum install -y epel-release安裝擴展源
  • yum list|grep epel查看擴展源

 

yum下載rpm包

  • yum install -y 包名 --downloadonly //只下載包,不安裝。
  • ls /var/cache/yum/x86_64/7/  下載的包保存目錄
  • yum install -y 包名 --downloadonly --downloaddir=路徑   (指定下載的路徑)
  • yum reinstall -y 包名 --downloadonly --downloaddir=路徑  (reinstall從新安裝)

 下載的包保存目錄,從哪一個倉庫下載的就在哪一個文件夾下。.net

[root@glinux-01 ~]# ls /var/cache/yum/x86_64/7/
base  extras  timedhosts  timedhosts.txt  updates

源碼包安裝

示例:Apache源碼包安裝步驟

  • cd /usr/local/src/    源碼包放置地址,約定俗成的,方便尋找
  • wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.32.tar.gz //apache下載地址(地址網上找最新的)
  • tar zxvf httpd-2.2.32.tar.gz
  • cd httpd-2.2.32
  • ./configure --prefix=/usr/local/apache2(指定路徑爲/usr/local/apache2)
  • make
  • make install
  • 卸載就是刪除安裝的文件

下載後解壓 tar -zxvf httpd-2.4.29.tar.gz 

[root@glinux-01 src]# ls
httpd-2.4.29  httpd-2.4.29.tar.gz
[root@glinux-01 httpd-2.4.29]# ls
ABOUT_APACHE     BuildBin.dsp    emacs-style     LAYOUT        NOTICE            srclib
acinclude.m4     buildconf       httpd.dep       libhttpd.dep  NWGNUmakefile     support
Apache-apr2.dsw  CHANGES         httpd.dsp       libhttpd.dsp  os                test
Apache.dsw       CMakeLists.txt  httpd.mak       libhttpd.mak  README            VERSIONING
apache_probes.d  config.layout   httpd.spec      LICENSE       README.cmake
ap.d             configure       include         Makefile.in   README.platforms
build            configure.in    INSTALL         Makefile.win  ROADMAP
BuildAll.dsp     docs            InstallBin.dsp  modules       server

目錄中文件README,INSTALL通常是安裝信息 

[root@glinux-01 httpd-2.4.29]# cat INSTALL 

  APACHE INSTALLATION OVERVIEW

  Quick Start - Unix
  ------------------

  For complete installation documentation, see [ht]docs/manual/install.html or
  http://httpd.apache.org/docs/2.4/install.html

     $ ./configure --prefix=PREFIX    //指定安裝路徑
     $ make                           //譯成電腦識別的二進制文件
     $ make install                   //用於建立相關軟件的存放目錄和配置文件
     $ PREFIX/bin/apachectl start     //啓動方法

./configure --prefix=/usr/local/apache2  (還有不少選項,能夠./configure --help查看)指定路徑

[root@glinux-01 httpd-2.4.29]# ./configure --prefix=/usr/local/apache2
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
configure: 
configure: Configuring Apache Portable Runtime library...
configure: 
checking for APR... no
configure: error: APR not found.  Please read the documentation.
[root@glinux-01 httpd-2.4.29]# echo $?
1

竟然報錯。。。configure: error: APR not found.  Please read the documentation.

網上搜索的解決方案:https://www.cnblogs.com/visec479/p/5160297.html

echo $? 能夠檢測上一條命令執行正確(0)仍是錯誤(1)

下載apr軟件包:wget http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz 

  1. [root@xt test]# tar -zxf apr-1.4.5.tar.gz  解壓
  2. [root@xt test]# cd  apr-1.4.5  
  3. [root@xt apr-1.4.5]# ./configure --prefix=/usr/local/apr  安裝

又報錯!

[root@glinux-01 apr-1.4.5]# ./configure --prefix=/usr/local/apr
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.4.5
checking for chosen layout... apr
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/usr/local/src/apr-1.4.5':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.

安裝gcc    yum install gcc

從新安裝 :[root@xt apr-1.4.5]# ./configure --prefix=/usr/local/apr  安裝

從新安裝   ./configure --prefix=/usr/local/apache2 成功

make

make install

相關文章
相關標籤/搜索