SoFunction
Updated on 2025-03-03

The entire process of Linux installation and management software program

1. Several ways to install Linux

1. Source code compilation and installation (binary installation)

In fact, the source code package is a lot of source code programs written by programmers in specific formats and syntax.

After the source code package is successfully compiled, the binary package is generated and finally installed and written to the hard disk.

Since the binary package has been compiled before it is released, the user installs the software faster (as is the same as the software installation speed under Windows), and the probability of an error during the installation process is greatly reduced.

advantage:

  • Open source. If you have enough ability, you can modify the source code.
  • You can freely choose the required functions.
  • Because the software is compiled and installed, it is more suitable for your system, more stable and more efficient.
  • Easy to uninstall.

insufficient:

  • There are many steps in the installation process, especially when installing larger software collections (such as LAMP environment construction), which are prone to spelling errors.
  • The compilation time is longer, so the installation time is longer than that of binary installation.
  • Because the software is compiled and installed, it is difficult for novices to solve the problem if an error is reported during the installation process.

Install

Proposed by Red Hat, it has been adopted by many Linux distributions to establish a unified database file (a corresponding table writes information) and records the changes in software package installation, uninstallation, and automatically analyzes the software package dependencies.

advantage:

  • Unified installation package format
  • It has been compiled for you
  • Easy to use

insufficient:

  • Because the software has a dependency relationship, you need to manually download each dependency package first (it is too cumbersome and basically not needed when installing the software)

Software Repository

Born to resolve rpm package dependencies

advantage:

  • Easy to install
  • Automatically resolve dependencies

4. Download the installation package

2. Install management software program

Several ways to get software packages

  • Red Hat Official
  • Provided by third-party organizations
  • Software project official site
  • Made yourself

The following practical demonstration shows how to install software programs by mounting the image file and obtaining the rpm installation package in it.

Mounting:

  • Everything in Linux is a file. No matter the hardware software, it must be used as a file. The hardware cannot be used directly as a file. Adding the hard disk can only operate in the root partition.
  • Mounting is to associate the hardware with a folder in the root partition, which is equivalent to this folder being an entrance to the hard disk.

Package management tool

(1) General naming format

bash-4.1.2-15.el6_4.x86_64.rpm

bash—shell environment 4.1.2—version information 15—number of releases x86_64—system architecture

(2) Classification after unpacking

[root@localhost Packages]# ll httpd*
-rw-rw-r--. 2 root root 2835196 8moon 11 2017 httpd-2.4.6-67..x86_64.rpm
-rw-rw-r--. 2 root root 197360 8moon 11 2017 httpd-devel-2.4.6-67..x86_64.rpm
-rw-rw-r--. 2 root root 1402824 8moon 11 2017 httpd-manual-2.4.6-67.
-rw-rw-r--. 2 root root 89284 8moon 11 2017 httpd-tools-2.4.6-67..x86_64.rpm
// Main package Development Package Manual Package Toolkit

(3) Package Manager related files

- Package file composition (each package is unique)

  • Files in the package
  • Metadata, such as: package name, version, dependency, description, etc.
  • There may be scripts that run when packages are installed or uninstalled

- Database (public): /var/lib/rpm (After installation, some public data will be placed into the database)

  • Package name and version
  • Dependencies
  • Function description
  • The paths and verification code information generated after the package is installed

(4) Command to query installation package information

Query whether the specified software is installed

rpm -q Software name

Query the installed software information

  • -qa //Show all software lists installed in the current system in RPM
  • -ql //Show all directories and files lists installed in the current system by the specified software package.
  • -qi //View detailed information such as the name, version, license agreement, purpose description of the specified software package, etc.
  • -qc // List the configuration files of the installed specified software
  • -qd // List the package document location of the specified software installed.
  • -qf //View which software package is installed by the specified file or directory

Query the installed package information

  • -qpl //Show all directories and files lists installed in the current system by the specified software package.
  • -qpi //View detailed information such as the name, version, license agreement, purpose description of the specified software package, etc.
  • -qpc //list the configuration files of the installed specified software
  • -qpd // List the package document location of the specified software installed.

(5) rpm installation management software

[root@localhost Packages]# rpm -i software name //rpm installation software
-v //Display process
-h //Show progress bar########
-e //Uninstall the software
-U //Upgrade software(Need an upgrade package)
//No dependency, installation is successful[root@localhost Packages]#rpm -ivh tree-1.6.0-10.el7.x86_64.rpm
warning: tree-1.6.0-10.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:tree-1.6.0-10.el7                ################################# [100%]

//There is a dependency package, and the dependency package needs to be installed manually[root@localhost Packages]#rpm -ivh httpd-2.4.6-67..x86_64.rpm 
mistake:Dependency detection failed:
	httpd-tools = 2.4.6-67. quilt httpd-2.4.6-67..x86_64 need
[root@localhost Packages]#rpm -ivh httpd-tools-2.4.6-67..x86_64.rpm 
Preparing...                          ################################# [100%]
Upgrading/Install...
   1:httpd-tools-2.4.6-67.  ################################# [100%]
[root@localhost Packages]#rpm -ivh httpd-2.4.6-67..x86_64.rpm 
Preparing...                          ################################# [100%]
Upgrading/Install...
   1:httpd-2.4.6-67.        ################################# [100%]

2. Source code compilation and installation

(1) Source code

Most of them are developed in C language, which is more convenient to use

  1. The software version is relatively new, new features, and bug fixes
  2. You can define the path to the configuration file by yourself
  3. The source code may have 100 functions. Red Hat thinks you may not need to handle it yourself and cut it off. Customize it yourself 50.

(2) Package Compilation and Installation

Source Code --> Preprocessing --> Compile --> Assembly --> Link --> Execution

Multi-file: There is a cross-file dependency between the codes in the file. Although many open source software packages the software for people to use, not all source codes are packaged. If you want to use open source software, you may need to download the source code yourself and compile and install it.

In addition, even if the package is provided, some features of the software need to be used in production still need to be compiled and installed by yourself.

However, it is quite cumbersome to use source code to compile and install. Fortunately, there are related project management tools that can greatly reduce the complexity of the compilation process.

(3) Steps

Step 1: ./configure script written by the author of the software (there will be in the installation package)

  • You can change your installation path.
  • Select the function you want to install the software
  • Detect your installation environment

Step 2: Make compile the source code into a binary language

Common compilation software gcc gcc-c++

Step 3: make install Write binary data to the hard disk and install it into the system

(4) Source code compilation and installation practice

[root@localhost ~]#mkdir /app /data
[root@localhost data]#ls
httpd-2.4..bz2

//Decompression installation package[root@localhost data]#tar xf httpd-2.4..bz2

//Enter the installation package[root@localhost data]#cd httpd-2.4.29

//Installing the toolkit required by the dependent environment[root@localhost httpd-2.4.29]#yum install apr* gcc* pcre* -y

//Configure the installation path to /app[root@localhost httpd-2.4.29]#./configure --prefix=/app

//Use to compile with 2 cpu[root@localhost httpd-2.4.29]#make -j2

//Installing and writing to the hard disk[root@localhost httpd-2.4.29]#make install

//Check whether the installation is successful - whether the httpd web service is enabled[root@localhost httpd-2.4.29]#/app/bin/apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified this message

//Port 80 open instructions Web service is enabled[root@localhost httpd-2.4.29]#ss -ntap |grep 80
LISTEN     0      128       [::]:80                    [::]:*                   users:(("httpd",pid=25821,fd=4),("httpd",pid=25820,fd=4),("httpd",pid=25819,fd=4),("httpd",pid=25818,fd=4))

Install management software

yum is a software update mechanism built on RPM packages. It can automatically resolve the dependencies between software packages and solve the problem of finding and installing dependencies in daily work.

[root@localhost Packages]# yum [Options] Action Package
-y install //Select all yes prompts for installation process
-q install //The installation process is not displayed
info //Show installation package information
list //No package name to display all installed and installed package information
deplist // Check the package dependency
remove //Uninstall the software
clean //Clean up software packages in the cache directory

(1) c/s architecture

A server is needed to provide services

To become a server, you must have the following two folders Packages and repodata

  • Packages - Installation packages (Packages are not fixed, but they are called Packages)
  • repodata—Metadata (install package path, dependencies, metadata, etc.)

Client

  • The client needs to configure a file to indicate the path to the server
  • The client's configuration file is fixed at /etc// (the client configuration file must end in .repo)

(2) Installation process

  • The first time the client connects to the server, it will save the metadata file;
  • Then, based on the dependencies and package paths in the metadata, download all the required installation packages and put them in the cache directory;
  • After the installation is completed, all installation packages in the cache directory are deleted.

(3) Configure the local yum source

Generally speaking, the default warehouse path requires access to the Internet. When we cannot access the Internet, we need to build a local yum warehouse. In this way, the client can install software through the local yum warehouse, etc.

To build a local yum warehouse, you need to:

Server side

  • Installation Packages: through mount, copy, etc.
  • Metadata repodata: by self-generating, copying, etc.

Client

Handwritten configuration file (ends with .repo)

//General format of configuration file[base]           --The name of the warehouse,Customize
name=CentOS-$releasever - Base     --Description of the warehouse,Customize
baseurl=/centos/$releasever/os/$basearch/   --The path to the warehouse server
gpgcheck=1      --Check the safety and integrity of the package(1Represents need,0It means no need)
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 --If gpgcheck=1, you need to specify the location of the verification fileenabled=1            --It means that the repository is enabled(1Representative to enable,0Representative Close,If not written, turn on by default)

Note:
Warehouse server baseurl There are four ways to express it
file:// --Local path (the path of the current system)http:// --The form of web pagehttps:// --Encryptionftp://        --File sharing service to implement

(4) yum installation software operation

//Get the installation package by mount[root@localhost ~]#mount /dev/sr0 /mnt
mount: /dev/sr0 Write protection,Will be mounted read-only

//Switch to the yum source configuration directory[root@localhost ~]#cd /etc//

//ls view the directory has many yum sources[root@localhost ]#ls
         
               CentOS-x86_64
  

// Create a new bak directory and move the original yum source into[root@localhost ]#mkdir bak
[root@localhost ]#mv * bak/
[root@localhost ]#ls bak
         
               CentOS-x86_64
  

//Create a new local yum source configuration file and edit it[root@localhost ]#vim 
[local]
name=local
baseurl=file:///mnt
gpgcheck=0
enabled=1

//Clean yum cache directory[root@localhost ]#yum clean all
Plugin loaded:fastestmirror, langpacks
Cleaning up software sources: local
Cleaning up list of fastest mirrors
Other repos take up 850 M of disk space (use --verbose for details)

//Re-establish source data[root@localhost ]#yum makecache 
Plugin loaded:fastestmirror, langpacks
Determining fastest mirrors
local                                                    | 3.6 kB     00:00     
(1/4): local/group_gz                                      | 153 kB   00:00     
(2/4): local/filelists_db                                  | 3.3 MB   00:00     
(3/4): local/primary_db                                    | 3.3 MB   00:00     
(4/4): local/other_db                                      | 1.3 MB   00:00     
Metadata cache has been established

//Try to download the software through the local yum source (taking php as an example)[root@localhost ]#yum install php -y
Plugin loaded:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving dependencies
--> Checking transactions
---> Software Package php.x86_64.0.5.4.16-48.el7 Will be Install
--> Dependency is being processed php-common(x86-64) = 5.4.16-48.el7,它被Software Package php-5.4.16-48.el7.x86_64 need
...
已Install:
  php.x86_64 0:5.4.16-48.el7                                                    

作为依赖被Install:
  httpd.x86_64 0:2.4.6-95.  httpd-tools.x86_64 0:2.4.6-95. 
  libzip.x86_64 0:0.10.1-8.el7         0:2.1.41-2.el7            
  php-cli.x86_64 0:5.4.16-48.el7      php-common.x86_64 0:5.4.16-48.el7        

complete!              --Install成功,Description of localyumSource can be used

Summarize

The above is personal experience. I hope you can give you a reference and I hope you can support me more.