A Du Xue Linux Lecture 22

Posted by literom on Wed, 19 Jun 2019 02:59:50 +0200

7.6 yum Replacement of Domestic Sources

  • Restore the default yum source configuration of the system:
[root@adai002 Packages]# cd /etc/yum.repos.d
[root@adai002 yum.repos.d]# ls
dvd.repo
[root@adai002 yum.repos.d]# rm -f dvd.repo
[root@adai002 yum.repos.d]# ls
[root@adai002 yum.repos.d]# cp ../yum.repos.d.bak/* .
[root@adai002 yum.repos.d]# ls
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo
  • Custom yum source:
[root@adai002 yum.repos.d]# rm -f CentOS-Base.repo

First delete the default yum source, and then use the wget command to create a new yum source:

[root@adai002 yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
 - bash: wget: No command found

At this time, the wget command is not installed, and the yum source file is deleted, so the wget package cannot be installed.
So use the following method: "curl command"

[root@adai002 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   8959      0 --:--:-- --:--:-- --:--:--  8982
[root@adai002 yum.repos.d]# ls
CentOS7-Base-163.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
CentOS-CR.repo         CentOS-fasttrack.repo  CentOS-Sources.repo

Description: After executing curl command, the original Yum source file CentOS-Base.repo was replaced by CentOS7-Base-163.repo. View the yum source file:

[root@adai002 yum.repos.d]# vim 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
 "CentOS7-Base-163.repo" 41L, 1572C          

The address of the mirror file was changed to "baseurl"= http://mirrors.163.com/centos/$releasever/os/$basearch/".

Note: The yum source used in this process needs to be downloaded beforehand.

Finished!

7.7 yum download rpm package

Install extended source epel

Install an extended source file (epel-release):

[root@adai002 yum.repos.d]# ls
CentOS7-Base-163.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
CentOS-CR.repo         CentOS-fasttrack.repo  CentOS-Sources.repo
[root@adai002 yum.repos.d]# yum install -y epel-release
......
//Installed:
  epel-release.noarch 0:7-9 

//Complete!
[root@adai002 yum.repos.d]# ls
CentOS7-Base-163.repo  CentOS-fasttrack.repo  CentOS-Vault.repo
CentOS-CR.repo         CentOS-Media.repo      epel.repo
CentOS-Debuginfo.repo  CentOS-Sources.repo    epel-testing.repo

After installation, add "epel.repo" and "epel-testing.repo" under yum.repos.d/:

[root@adai002 yum.repos.d]# cat epel.repo
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
......

See:

[root@adai002 yum.repos.d]# yum list
......
zulucrypt-doc.noarch                             5.0.1-1.el7                          epel     
zulucrypt-libs.x86_64                            5.0.1-1.el7                          epel     
zvbi.x86_64                                      0.2.35-1.el7                         epel     ......

Many rpm packages from epel libraries have been added.

Download rpm package

download

Command: Yum install-y [package name] -- download only

[root@adai002 yum.repos.d]# yum install -y  zsh --downloadonly
//Loaded plug-in: fastest mirror
Loading mirror speeds from cached hostfile
......
zsh-5.0.2-25.el7_3.1.x86_64.rpm                                         | 2.4 MB  00:00:02     
exiting because "Download Only" specified
[root@adai002 yum.repos.d]# rpm -q zsh
//Uninstalled package zsh 

That is, the meaning of this command is to download only and not install.
The default location for downloaded packages is:

[root@adai002 yum.repos.d]# ls /var/cache/yum/x86_64/7/updates/packages
zsh-5.0.2-25.el7_3.1.x86_64.rpm

Custom Download Directory

Command: Yum install-y [package name] -- download only -- download dir=/tmp/(custom directory)

[root@adai002 yum.repos.d]# yum install -y  zsh --downloadonly --downloaddir=/tmp/
[root@adai002 yum.repos.d]# ls /tmp/
zsh-5.0.2-25.el7_3.1.x86_64.rpm

Download an installed package:

[root@adai002 yum.repos.d]# yum install -y  vim-enhanced --downloadonly --downloaddir=/tmp/
Loaded plug-in: fastest mirror
Loading mirror speeds from cached hostfile
 * epel: mirror01.idc.hinet.net
 Package 2:vim-enhanced-7.4.160-1.el7_3.1.x86_64 is installed and the latest version
 No treatment is required.
[root@adai002 yum.repos.d]# yum reinstall -y  vim-enhanced --downloadonly --downloaddir=/tmp/
Loaded plug-in: fastest mirror
......
[root@adai002 yum.repos.d]# ls /tmp/
vim-enhanced-7.4.160-1.el7_3.1.x86_64.rpm
zsh-5.0.2-25.el7_3.1.x86_64.rpm

Description: When the next package has been installed, the system will not perform any operations, at this time you can use "reinstall" to download the package.

7.8-7.9 Source Pack Installation

Download a source package first!
Note: In the future, all source packages will be placed in the directory "/ usr/local/src /"!!

[root@adai002 src]# wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.32.tar.gz  
//Download Apache! The address comes from "Amin City".
//Unzip the file after downloading:
[root@adai002 src]# tar zxvf httpd-2.2.32.tar.gz
[root@adai002 src]# ls
httpd-2.2.32  httpd-2.2.32.tar.gz

//View the contents of the file httpd-2.2.32:

[root@adai002 src]# cd httpd-2.2.32
[root@adai002 httpd-2.2.32]# ls
ABOUT_APACHE  CHANGES        httpd.dsp       libhttpd.dep  NOTICE            server
acinclude.m4  config.layout  httpd.mak       libhttpd.dsp  NWGNUmakefile     srclib
Apache.dsw    configure      httpd.spec      libhttpd.mak  os                support
build         configure.in   include         LICENSE       README            test
BuildAll.dsp  docs           INSTALL         Makefile.in   README.platforms  VERSIONING
BuildBin.dsp  emacs-style    InstallBin.dsp  Makefile.win  README-win32.txt
buildconf     httpd.dep      LAYOUT          modules       ROADMAP

Install Apache:

① 
[root@adai002 httpd-2.2.32]# ./configure --prefix=/usr/local/apache2
checking for chosen layout... Apache
checking for working mkdir -p... yes
......
checking for chosen layout... apr
checking for gcc... no
checking for cc... no

When a command is finished, use "echo $?" to verify that it is correct:

[root@adai002 httpd-2.2.32]# echo $?
1
 When this value is 0, the previous command is correct, and if it is 1, it is wrong.
The value here is 1, that is, the above command error. Looking at its installation process, we found that "checking for gcc... no" - meaning that the "gcc" compiler does not exist, so we need to install the gcc compiler first:
[root@adai002 httpd-2.2.32]# yum install -y gcc
............
Complete!
[root@adai002 httpd-2.2.32]# ./configure --prefix=/usr/local/apache2
 Install again.
[root@adai002 httpd-2.2.32]# echo $?
0
 Detection, correct.
②
[root@adai002 httpd-2.2.32]# make compilation!
......
[root@adai002 httpd-2.2.32]# echo $?
0

③
[root@adai002 httpd-2.2.32]# make install
......
[root@adai002 httpd-2.2.32]# echo $?
0
 After each command is executed, it is checked with "echo $?" to make sure it is correct.
Installation completed!
View the contents of its installation directory:
[root@adai002 httpd-2.2.32]# ls /usr/local/apache2/
bin  build  cgi-bin  conf  error  htdocs  icons  include  lib  logs  man  manual  modules

Note: Download the source package to the official website or trusted site - safe!

Topics: yum CentOS EPEL RPM