yum replaces the domestic source, yum downloads the rpm package, and installs the source package

yum replace domestic source

  • Delete foreign source 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]# 
[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]# 

Then you can install an rpm package and try it

[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]# 

Install the extension source 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]# 

Two more installation sources

yum download rpm package

  • Only download but not install: [root@localhost yum.repos.d]# yum install zsh --downloadonly

  • The download location is: /var/cache/yum/x86_64/7/warehouse name/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
  • Specify the download directory: -- 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]# 
  • If you download an rpm package that has already been installed, it will prompt that it has been installed and will not be downloaded. In addition to uninstalling the installed package and downloading it again, there is another way: 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 将被 已重新安装
--> 解决依赖关系完成

Source package installation

  • First, you need to download a source package according to your needs

    Convention: After the source code package is downloaded, put it under cd /usr/local/src/

  • You can download an apache for installation experiment

[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
  • Unzip the package: tar zxvf -zxvf httpd-2.2.32.tar.gz

  • View source package

[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]# 
  • View the source package INSTALL file, there are prompts for installation method

    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
  • Install the source package

[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]# 

There is an error when this command is executed. Check if there is an error in the execution of the previous command, enter "echo $?". The output result is not 0, indicating that there is an error

The error indicates that gcc does not exist. In this case, yum install it, yum install gcc

  • Then install it again and see if there is any error. If there is any error, it will stop and tell where there is a problem.

[root@localhost httpd-2.2.32]# echo $?
0

After installation, check that echo $? is 0, indicating that there is no problem

  • Then it's time to make

Wait for about two minutes to complete, and then check if there are any errors

[root@localhost httpd-2.2.32]# echo $?
0
  • After that make install

This command is to install the compiled file

See what's installed in the directory


[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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324600993&siteId=291194637