Linux Installation and management program: rpm software package and source code installation (the most beautiful place of time is to make you and I become us)

Posted by KingWylim on Sun, 20 Feb 2022 00:18:27 +0100

catalogue

1, Linux Application Foundation

1. Relationship between application program and system command

 2. Common package encapsulation types

2, RPM package management tool

1.Red-  Hat Package Manager

2.RPM software package

3.rpm command function

4. Query RPM package information

5. Install, upgrade and uninstall RPM software package

6. Maintain RPM database

7. Solutions to software package dependencies

8. Mounting operation before installation

9. Example: rpm installation tree

3, Source code compilation and installation

1. Advantages of source code compilation and installation

2. Compilation and installation process

3. Example: source code compilation and installation httpd

4, Summary

1, Linux Application Foundation

1. Relationship between application program and system command

roleSystem commandapplication program
file locationIt is usually in / bin and / sbin directories, or it is an internal command of the shellUsually in / usr/bin and / usr/sbin directories
Main purposeComplete the basic management of the systemComplete other relatively independent auxiliary tasks, such as web browser
Applicable environmentGenerally, it only runs in the character operation interfaceAccording to the actual needs, some programs can be run in the graphical interface
Run formatIt generally includes command words, command options and command parametersThere is usually no fixed execution format

Commands can be understood as applications, but applications are external commands

Example:

1. To close the firewall, you can use the command to close it or close it in the graphical interface

  • Command to turn off the firewall
systemctl stop firewalld.service
  • Graphical interface turn off firewall

 

 

 2. Common package encapsulation types

file typeSave directory
RPM packageExtension is ". rpm"
DEB packageExtension is ". deb"
Source code packageGenerally, the compressed package in the format of ". tar.gz" and ". tar.bz2" contains the original code of the program
Green installation free software package

Software packages have different extensions, mostly in TarBall format

Provide compiled executor files in the compressed package

Unpacked files can be used directly

  1. Although Linux does not use suffixes as file types, sometimes extensions are written for ease of viewing
  2. The rpm package is packed by red hat company for you. Generally, there will be no bug s. You'd better go to the official website
  3. deb package is used more in Ubuntu. We use red hat and cento more, just for understanding
  4. The source code needs to be compiled into binary files for hardware. The source code package will be described in detail later
  5. Green installation package is similar to the program that can be executed directly without installation in windows

2, RPM package management tool

1.Red-  Hat Package Manager

  1. Proposed by Red Hat and adopted by many Linux distributions
  2. Establish a unified database file
  3. Record the change information of software package installation and uninstall in detail
  4. Automatically analyze package dependencies

2.RPM software package

  1. Software material reference: http: www.rpm org
  2. General naming format: bash-4.1.2-15 el6_ 4.x86_ 64.rpm

bash running environment (here is the software package)

4.1.2 version information

15 number of releases

e16 stands for red hat 6 or centos6

x86_64 (hardware platform) is the architecture

rpm is the extension

Each dependency requires manual installation

3.rpm command function

  1. Query and verify relevant information of RPM software package
  2. Install, upgrade, uninstall RPM packages
  3. Maintain RPM database information and other comprehensive management operations

4. Query RPM package information

[root@localhost data]# rpm -qa   #View all installed packages
------------------------------------Split line-------------------------------------------
[root@localhost data]# rpm -qi tree  #View details
Name        : tree
Version     : 1.6.0
Release     : 10.el7
Architecture: x86_64
Install Date: 2022 Thursday, February 17, 2014 14:17:44
Group       : Applications/File
Size        : 89505
License     : GPLv2+
Signature   : RSA/SHA256, 2014 Friday, July 4, 2013 13:36:46, Key ID 24c6a8a7f4a80eb5
Source RPM  : tree-1.6.0-10.el7.src.rpm
Build Date  : 2014 Tuesday, June 10, 2003 03:28:53
Build Host  : worker1.bsys.centos.org
Relocations : (not relocatable)
Packager    : CentOS BuildSystem <http://bugs.centos.org>
Vendor      : CentOS
URL         : http://mama.indstate.edu/users/ice/tree/
Summary     : File system tree viewer
Description :
The tree utility recursively displays the contents of directories in a
tree-like format.  Tree is basically a UNIX port of the DOS tree
utility.
------------------------------------Split line-------------------------------------------
[root@localhost data]# rpm -ql tree   #Show file list
/usr/bin/tree
/usr/share/doc/tree-1.6.0
/usr/share/doc/tree-1.6.0/LICENSE
/usr/share/doc/tree-1.6.0/README
/usr/share/man/man1/tree.1.gz
------------------------------------Split line-------------------------------------------
[root@localhost data]# which ls  #Locate the installation location of the command
alias ls='ls --color=auto'
	/usr/bin/ls
[root@localhost data]# rpm -qf /usr/bin/ls  #View the installation package of this command
coreutils-8.22-21.el7.x86_64
------------------------------------Split line-------------------------------------------
[root@localhost data]# rpm -qc httpd  #View the configuration file conf ends with the configuration file
/etc/httpd/conf.d/autoindex.conf
/etc/httpd/conf.d/userdir.conf
/etc/httpd/conf.d/welcome.conf
/etc/httpd/conf.modules.d/00-base.conf
/etc/httpd/conf.modules.d/00-dav.conf
/etc/httpd/conf.modules.d/00-lua.conf
/etc/httpd/conf.modules.d/00-mpm.conf
/etc/httpd/conf.modules.d/00-proxy.conf
/etc/httpd/conf.modules.d/00-systemd.conf
/etc/httpd/conf.modules.d/01-cgi.conf
/etc/httpd/conf/httpd.conf
/etc/httpd/conf/magic
/etc/logrotate.d/httpd
/etc/sysconfig/htcacheclean
/etc/sysconfig/httpd
------------------------------------Split line-------------------------------------------
[root@localhost data]# rpm -qd httpd   #View help documentation
/usr/share/doc/httpd-2.4.6/ABOUT_APACHE
/usr/share/doc/httpd-2.4.6/CHANGES
/usr/share/doc/httpd-2.4.6/LICENSE
/usr/share/doc/httpd-2.4.6/NOTICE
/usr/share/doc/httpd-2.4.6/README
/usr/share/doc/httpd-2.4.6/VERSIONING
/usr/share/doc/httpd-2.4.6/httpd-dav.conf
/usr/share/doc/httpd-2.4.6/httpd-default.conf
/usr/share/doc/httpd-2.4.6/httpd-info.conf
/usr/share/doc/httpd-2.4.6/httpd-languages.conf
/usr/share/doc/httpd-2.4.6/httpd-manual.conf
/usr/share/doc/httpd-2.4.6/httpd-mpm.conf
/usr/share/doc/httpd-2.4.6/httpd-multilang-errordoc.conf
/usr/share/doc/httpd-2.4.6/httpd-vhosts.conf
/usr/share/doc/httpd-2.4.6/proxy-html.conf
/usr/share/man/man8/apachectl.8.gz
/usr/share/man/man8/fcgistarter.8.gz
/usr/share/man/man8/htcacheclean.8.gz
/usr/share/man/man8/httpd.8.gz
/usr/share/man/man8/rotatelogs.8.gz
/usr/share/man/man8/suexec.8.gz

Summary:

  1. -qa all installed software packages in the current system
  2. -qi details
  3. -ql specifies the directory list of the software
  4. -qc profile
  5. -qd configuration document of installed software
  6. -qf reverse view the installation package name of the program
#If you are looking at an uninstalled package, we don't know the full name of the package, so we need to check the name first
[root@localhost data]# ls /mnt/Packages/ |grep tree   #View the full name of an uninstalled package
texlive-pst-tree-svn24142.1.12-38.el7.noarch.rpm
tree-1.6.0-10.el7.x86_64.rpm
[root@localhost data]# cd /mnt/Packages/    #You need to enter this directory before you can view it
[root@localhost Packages]# rpm -qpi tree-1.6.0-10.el7.x86_64.rpm   #View information about packages that are not installed
Name        : tree
Version     : 1.6.0
Release     : 10.el7
Architecture: x86_64
Install Date: (not installed)
Group       : Applications/File
Size        : 89505
License     : GPLv2+
Signature   : RSA/SHA256, 2014 Friday, July 4, 2013 13:36:46, Key ID 24c6a8a7f4a80eb5
Source RPM  : tree-1.6.0-10.el7.src.rpm
Build Date  : 2014 Tuesday, June 10, 2003 03:28:53
Build Host  : worker1.bsys.centos.org
Relocations : (not relocatable)
Packager    : CentOS BuildSystem <http://bugs.centos.org>
Vendor      : CentOS
URL         : http://mama.indstate.edu/users/ice/tree/
Summary     : File system tree viewer
Description :
The tree utility recursively displays the contents of directories in a
tree-like format.  Tree is basically a UNIX port of the DOS tree utility.

The query operation of the uninstalled software package is similar to that of the installed software package. The difference is that there are multiple p parameters

5. Install, upgrade and uninstall RPM software package

Syntax format:

RPM [options] RPM package file

Example:

#Installation package i installation v details h humanization, display (progress bar)
[root@localhost Packages]# rpm -ivh tree-1.6.0-10.el7.x86_64.rpm   
In preparation...                          ################################# [100%]
	software package tree-1.6.0-10.el7.x86_64 Already installed
 
[root@localhost Packages]# rpm -e tree  #Delete this package
[root@localhost Packages]# rpm -q tree  #Check this package and you can see that it has been deleted
 Package not installed tree 

Summary:

  1. -e) delete
  2. -i) installation
  3. -q) view package information
  4. -v) display details
  5. -h. humanized display (progress bar)

6. Maintain RPM database

1. Rebuild RPM database

[root@localhost ~]#rpm --rebuilddb
#perhaps
[root@localhost ~]# rpm --initdb

2. Import verification public key

[root@localhost ~]# rpm --import /media/cdrom/RPM-GPG-KEY-CentOS-7

7. Package dependency resolution

When installing multiple dependent software: the dependent software package needs to be installed first, and multiple software packages can be specified at the same time Install with rpm package file

When uninstalling multiple dependent software: software packages that depend on other programs need to be uninstalled first. You can specify multiple software names to uninstall at the same time

Ignore dependencies: combine the "-- nodeps" option, but it may cause software exceptions

8. Mounting operation before installation

Why mount and the principle of mount? I'll write a separate blog later and post the link

Therefore, the real Linux system is not just a few hundred megabytes, and the image files are mostly software packages

9. Example: rpm installation tree

 

 

The tree package is very small, so it is very convenient to demonstrate, while other software installations have many dependencies, so I won't demonstrate it, because rpm installation is almost unnecessary in work

A bad thing about using rpm package to install software is to guide the whole process of software package, so we use yum to install it in our work

3, Source code compilation and installation

 

1. Advantages of source code compilation and installation

  1. Keep all functions, while rpm will castrate some functions
  2. Easy to manage
  3. Get the latest software version and fix bug s in time
  4. Flexibly customize software functions according to user needs

2. Compilation and installation process

  1. Download the source code installation package file
  2. tar unpacking: unzip and release the source code package to the specified directory
  3. . / configure configuration: set installation directory, installation module and other options
  4. make compilation: generates executable binary files
  5. make install: copy binary files to the system and configure the application environment
  6. Test, application and maintenance software

3. Example: source code compilation and installation httpd

1. Go to the official website of apache to download, and right-click on the download page to copy the link address

http://httpd.apache.org/

 2. Download package

wget https://dlcdn.apache.org//httpd/httpd-2.4.52.tar.bz2

Displays the certificate expiration, followed by a parameter

wget https://dlcdn.apache.org//httpd/httpd-2.4.52.tar.bz2 --no-check-certificate

Or you can download it in windows and drag it into xshell, which is more convenient

3. Unzip the package

tar xvf httpd-2.4.52_.tar.bz2

Decompression complete

4. Enter the extracted directory and execute the executable file

[root@localhost httpd-2.4.52]# ./configure --prefix=/usr/local/apache
#--prefix = specify the directory to execute to

 

The error display requires APR, so we need to install APR first

[root@localhost httpd-2.4.52]# yum install -y apr*   #Install apr related files

apr installation completed

Re execute the previous command/ configure --prefix=/usr/local/apache, showing missing pcre

[root@localhost httpd-2.4.52]# yum install -y pcre*  #Install pcre
[root@localhost httpd-2.4.52]#./configure --prefix=/usr/local/apache    #Execute this command again

At this time, the configuration installation is successful

5. Compile make and press the make command

6.make install installation, click the make install command

 

systemctl stop firewalld  #Turn off the firewall
setenforce 0  #Turn off the firewall

Then access the IP address of your virtual machine in the browser

In this way, the normal installation is successful

4, Summary

rpm installation can master these items, which are basically not used in the later stage

  1. rpm -ivh# software package # install software
  2. rpm -e # software package # delete software
  3. rpm -qi# package # view package information

Source code installation

  1. Download the source code installation package file
  2. tar unpacking: unzip and release the source code package to the specified directory
  3. . / configure configuration: set installation directory, installation module and other options
  4. make compilation: generates executable binary files
  5. make install: copy binary files to the system and configure the application environment
  6. Test, application and maintenance software

Topics: Linux Operation & Maintenance server