Chapter III installation and management procedures of Linux

Chapter III installation and management procedures of inux

preface

After the Linux operating system is installed in the host, it has the foundation to provide software services, network services and other functions. However, there are only a few software packages installed with the operating system after all, and the functions realized are relatively limited. When it is necessary to provide more functions for the host, installing new applications has become an inevitable task. This article will briefly explain how to install and manage applications in Linux system.

1, Linux Application Foundation

1. Relationship between application program and system command

  role                   System command                                 application program
 The file location is generally/bin and/sbin Directory, or Shell Internal command      Usually in/usr/bin and/usr/bin In the directory       
                                 
It is mainly used to complete the basic management of the system, such as IP Configuration tool        Complete other relatively independent auxiliary tasks, such as web browser             
                                     
Applicable environment        Generally, it only runs in the character operation page                According to the actual needs, some programs can be run in the graphical interface
                                   
The running format generally includes command words, command options and command parameters                    There is usually no fixed execution format   

2. Directory structure of typical applications

 file type                                           Save directory
 Common executor files (all users)                        /usr/bin
 Server executor files and hypervisor files (administrator)            /usr/sbin
 Application profile                                      /etc
 log file                                           /var/log
 Application reference document file (program generated file, program comes with)       /usr/share/doc                   
Application manual page document (manual)                 /usr/share/man

3. Common package encapsulation types

 file type                                  Save directory
RPM Software package (CD-ROM)                     Extension named“.rpm"
DEB software package                               Extension named“.deb"
Source code package                    Generally“.tar.gz",".tar.bz2"Equal format  
                                  Compressed package, containing the original code of the program
 Green installation free software package               The extensions of software packages are different, so TarBall Most of the format
                               Provide compiled executor files in the compressed package
                               Unpacked files can be used directly

RPM package:

2, RPM

1.RPM package management tool

1.1Red-Hat Package Manager

Proposed by red hat and adopted by many Linux distributions
Establish a unified database file
Record the change information of software package installation and uninstall in detail
Automatic analysis of software package dependencies (informing software dependencies) cannot solve dependencies
Only problems can be found, but problems cannot be solved

1.2 RPM package

Software material reference: http://www.rpm.org

General naming format:
bash-4.1.2-15.el6_4.x86_64.rpm
Name version release times hardware platform extension name

Different versions have different functions
Dependent package and version matching

2. Format of RPM command

2.1 rpm command can realize almost all the management functions of RPM software package

2.2 execute the "man rpm" command to get detailed help on the rpm command

2.3 rpm command function

Query and verify the relevant information of RPM software package
Install, upgrade, uninstall RPM package
Maintain RPM database information and other comprehensive management operations

3. Query RPM package information

3.1 query the installed RPM software information

rpm  -q [Sub option]  [Software name]

Common options
-qa,-qi,-ql,-qf,-qc,-qb

rpm -q xxx Query whether the software package is installed
rpm -qa | grep xxx query xxx Has it been installed

Query the installed RPM software information:

rpm -qa | grep libvirt retrieves the libvirt file from the installed rpm software

3.2 query the information in the uninstalled RPM package file

rpm -qp [Sub option] RPM Package file

Common options
-qpi,-qpl,-qpc,-qpd

3.3 viewing RPM software commands

rpm -qa           Displays the names of all installed programs
rpm -qi Program name    Displays details of installed programs
rpm -ql Program name    Displays the file list of installed programs (list of files generated after installation)
rpm -qf Program name    Query which installation package the installed program belongs to (parent program, not necessarily every program)
rpm -qc Program name    Lists the profiles of installed programs
rpm -qd Program name    Lists the location of the package documentation for the installed program
rpm -qR Program name    List the software packages and files that the installed program depends on
rpm -qpi Program name displays details of programs that are not installed
rpm -qpl Program name displays a list of files for programs that are not installed
rpm -qpf The program name shows which program the uninstalled program belongs to
rpm -pqc Program name displays the configuration file of the program that is not installed
rpm -pqd Program name displays the location of the package documentation for programs that are not installed

View rpm -qi program name

View rpm -ql program name

View rpm -qf program name view rpm -qc program name view rpm -qd program name


View rpm -qR program name


View rpm -qpi program name

View rpm -qpl program name

View rpm -qpf program name view rpm -qpc program name


View rpm -qpd program name

3.4. Install, upgrade, uninstall RPM package

3.4.1 installing or upgrading RPM software

rpm  [option]  RPM Package file

Common options
-i,-U,-F

3.4.2 uninstall the specified RPM software

rpm -e Software name

Auxiliary options
–force,–nodeps,-h,-v

rpm -i  install
    -e  uninstall
    -U  Upgrade (upgrade the program whether it has been installed or not)
    -F  The program must have been installed on before it can be upgraded
  --force   force
  --nodeps  Do not check dependencies with other packages
    -v  show the procedures
    -h  During installation or upgrade#Show progress

rpm -ivh program name

rpm -evh program name

The above is rpm installation. It is found that the rpm installation program needs to enter the directory to be installed for operation, which is cumbersome

Use yum to install. The dependencies will be eliminated during installation, and yum will minimize the installation (the parameters in the installer cannot be modified, which will lead to incomplete functions)

yum -y install program name

3.5 maintain RPM database

3.5.1 rebuild RPM database

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

3.5.2 import verification public key

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

Key ID: there is a software locally. During the installation process, it will detect whether your key ID is the same as the key ID published on the official website, which proves that the software has not been tampered with and can be used. Installation is allowed; If it is different, it will prove that it has been tampered with, an error will be reported, and installation is not allowed. If there is a problem with the key ID, you can re import it into the CD to solve the problem.

3.6 solutions to software package dependencies

3.6.1 when installing multiple software with dependencies

The dependent packages need to be installed first
Multiple can be specified at the same time Install with rpm package file

3.6.2 when uninstalling multiple dependent software

Packages that depend on other programs need to be uninstalled first
You can specify multiple software names to uninstall at the same time

3.6.3 ignore dependencies

Combined with the "– nodeps" option, but may cause software exceptions

Analysis: when installing software A, you need to install software B that depends on software A
Similarly, when uninstalling, you need to uninstall software B before uninstalling software A

"– nodeps" does not check the dependency with other software packages, which will lead to unclean software uninstallation and software exceptions

III Overview of source code compilation

1. Advantages of using source code to install software

Get the latest software version and fix bug s in time
Flexibly customize software functions according to user needs

2. Application examples

When installing a newer version of the application
When the currently installed program cannot meet the needs
When new features need to be added to the application

3.Tarball packet

.tar.gz and tar.bz2 format is in the majority
Software material reference: http://sourceforge.net

4. Integrity verification

md5sum verification tool

5. Confirm the source code compilation environment

You need to install a compiler that supports C/C + + programming language, such as:
gcc,gcc-c++,make,...

Compile: translate the program into binary files
Software needs to be installed because of dependencies

6. Compilation and installation process

                 Download the source code installation package file
                  Step 1: tar Unpack
           purpose;Unzip and release the source code to the specified directory
              Step 2:./configure Configuration (determine the option of adding function)
           Purpose: set installation directory, installation module and other options
                 Step 3: make compile
             Purpose: generate executable binary files
              Step 4: make install install
         Purpose: copy binary files to the system and configure the application environment
                 Testing and application, maintenance software

6.1 tar unpacking

6.1.1 habitually release the software package to / usr/src / directory

6.1.2 source code file location after unpacking

 /usr/src/Software name-Version number/

For example:

[root@localhost ~]# tar zxf httpd-2.4.25.tar.gz -C /usr/src/
tar:        Archive command, release file
z:       call gzip Compress or decompress the program
x:         Untie.tar Package file in format
f:           Indicates the use of archive files
.tar.gz:        Archive file name
-C /usr/src/: Unzip the source code package and specify the release directory

6.2 ./configure configuration

6.2.1 use the configure script in the source directory

6.2.2 execute ". / configure --help" to view help

6.2.3 typical configuration options

 --prefix=Software installation directory

For example:

[root@localhost ~]# cd /usr/src/httpd-2.4.25/
[root@localhost httpd-2.4.25]# ./configure --prefix=/usr/local/apache
                                      If no configuration options are specified, the default values are used

6.3 make compilation and installation

6.3.1 compilation

Execute the make command

6.3.2 installation

Execute the make install command

For example:

 [root@localhost httpd-2.4.25]# make
 [root@localhost httpd-2.4.25]# make install

6.4 testing, application and maintenance software

6.4.1 before use

[root@localhost httpd-2.4.25]# vim /usr/local/apache/httpd.conf

6.4.2 starting Apache

[root@localhost httpd-2.4.25]# /usr/local/apache/bin/apachectl start

6.4.3 run lynx 127.0.0.1 to view the running status of native Apache

Modify the configuration file, domain name, and bind with the domain name

IV Installation and construction of apache

1. Dependent packages and configuration commands

tar xf apr-1.6.2.tar.gz
tar xf apr-util-1.6.0.tar.gz
tar xf httpd-2.4.29.tar.bz2
mv apr-1.6.2 httpd-2.4.29/srclib/apr
mv apr-util-1.6.0 httpd-2.4.29/srclib/apr-util
yum -y install gcc gcc-c++ make pcre-devel expat-devel perl

1.1 analysis

Dependent packages: apr       Support cross platform
       apr-util  apr tool kit
       pcre     lib Library, support regular expressions
       expat    C Voice development, support XML Document development library
       perl     regular expression 
pcre It's a C The regular expression function library of speech is a lightweight function library.
Perl Borrowed C,sed. awk,shell Script voice and many other program voice features, of which the most important feature is its internal integration of regular expression function.
apr Hope others window,linux The client access of the platform helps realize cross platform and cross system
 regular expression   --------Write some grammar in the web page

2. Experimental steps

1.Resolve dependencies
2.to configure
cd httpd-2.4.29
./configure
3.Compilation and installation
make && make install
4.Start service
/usr/local/apache2/bin/apachectl
5.The server verifies that the service is turned on
netstat -anpt | grep httpd If the service is enabled, the service name and port 80 will be displayed
6.Local test
 Open browser http://Localhost or http: / / native ip or command line curl http: / / native ip or curl http://localhost
7.Micro client test
 Open browser http://apache server ip

Note: the first two apr dependency packages are installed without yum
Because apach 2.4.29 is not compatible with any version of apr, when installing the apr package using yum install, click/ An error will be reported during configure, saying that apr cannot be found, which indicates a compatibility problem. Therefore, the specific version of apr package should be put into the srclib library.

Experimental analysis

1. Transmission installation package

2. Check whether the installation package exists

3. Unzip the installation package

tar zxvf apr-1.6.2.tar.gz

tar zxvf apr-util-1.6.0.tar.gz

tar jxvf httpd-2.4.29.tar.bz2

4. Put the dependency package into the apr file

Because it is found in this file when compiling and installing make.
Command:

[root@server2 ~]# mv apr-1.6.2 httpd-2.4.29/srclib/apr
[root@server2 ~]# mv apr-util-1.6.0 httpd-2.4.29/srclib/apr-util
[root@server2 ~]# yum -y install pcre pcre-devel zlib-devel perl expat-devel

5. Check whether the dependent software is installed

rpm -qa | grep gcc
rpm -qa | grep make

6. Enter the home directory for configuration

[root@server2 ~]# cd httpd-2.4.29/
[root@server2 httpd-2.4.29]# ./configure

7. Compilation and installation can be carried out in two steps and one step at a time

[root@server2 httpd-2.4.29]# make && make install

8. After installation, go to the Apache 2 directory to find httpd Conf configuration file

[root@server2 httpd-2.4.29]# cd
[root@server2 ~]# cd /usr/local/apache2
[root@server2 apache2]# ls -l
[root@server2 apache2]# cd conf/
[root@server2 conf]# ls -l


Parsing: because the path of the configuration file is too long, create a short link to simplify the steps
/etc: store the configuration files of system programs and most application programs

9. Binding of website and domain name

Enter httpd Conf to modify the domain name
ServerName www.aaa.com:80
Change example to aaa server name (domain name)

10. Complete the bundling and restart the service

The configuration file has been modified and the service is restarted
Copy all files under apache2/bin / to / bin /

[root@server2 ~]# ln -s /usr/local/apache2/bin/* /bin/
[root@server2 ~]# Apache CTL at this point, Apache CTL starts
[root@server2 ~]# netstat -anpt | grep httpd
tcp6       0      0 :::80                   :::*                    LISTEN      94259/httpd  
                  80 Opening port No. indicates that the service is started

11. Test

Test after the service is started
ip test first
Test the ip address of the virtual machine http://20.0.0.11

Testing http://localhost/


Test ip address with real machine http://20.0.0.11

12. Modify the content of the home page

vi /usr/local/apache2/htdocs/index.html

index: Web page


lt works! Modified to surprised!

Exit save to see the effect

http://20.0.0.11
http://localhost

Complete the construction of apach

13. yum source installation and compilation installation

yum Source installation: minimization, incomplete functions
 Compilation and installation: full functions and multiple modules

13.1 viewing module commands

Compile and install: VI / ECT / httpd conf
More modules found (LoadModule)

Install httpd on another virtual machine first

yum -y install httpd
 View module
vi /etc/httpd/conf/httpd.conf
 Post search module
/LoadModule
 Find no result

14. Domain name addition

vi /etc/hosts
Add 20.0.0.11 www.aaa.com com

View effects on the website
www.aaa.com

It is invalid to specify aaa only in the configuration file of the web page. You must tell the host which domain name corresponds to (which object to visit) in the local mapping record
If Windows tests, you need to add or modify files
Add or modify in Disk C - Windows systems drivers etc hosts
20.0.0.11 www.aaa.com

Internet test
www.aaa.com

15 domain name resolution classification

Domain name resolution: static  /etc/hosts
                 dynamic  DNS    (Server)
At the same time, static priority is higher than dynamic priority

16. yum related commands

yum install:    yum -y install xxx
yum Uninstall:   yum -y remove  xxx
yum Clear cache: yum clean all
yum Create cache: yum makecache
yum Software update: yum update

For example:

yum -y install ftp

yum -y remove ftp

yum clean all      yum makecache

yum update

summary

Through the simulation of apache installation, this paper briefly explains how to install and manage applications in Linux system.

Tags: Linux

Posted by Seas.Comander on Thu, 12 May 2022 01:09:16 +0300