Installation and management of Linux packages

target content
rpm package management    
yum install package
Source code compilation and installation package


1. rpm package management
abbreviation: Redhat Package Manager

mainly includes RPM and YUM package management.
The two types of package management have their own advantages. The main differences are:
YUM is easy to use, and can be used locally or online. The network YUM source means that YUM will go to the YUM package source on the Internet to obtain the required software packages. The RPM needs to operate with relatively fine precision, and we need to do more things.

Mount the CD
[root@xuegod72 ~]# umount /dev/sr0 Unmount
[root@xuegod72 ~]# mount /dev/sr0 /media Mount
View the number of packages
[root@xuegod72 ~]# cd /media/Packages
[ root@xuegod72 Packages]# ls|wc -l

rpm package description:
zsh-5.0.2-14.el7.x86_64.rpm
      
zsh -5 0 . 2 -e17 x86 64
software name major version number minor version number revision number RHEL7 CPU Architecture platform supports system bits
Note : EL6 EL5

install rpm software
command: rpm [parameter] software package
Parameters :
 -i, --install install software package
 --nodeps do not verify package dependencies
 -v, --verbose provide more verbose output
 -h, --hash list hash tags when packages are installed

Installation
example [root@xuegod72 Packages]# rpm -ivh mariadb-server-5.5.44 -2.el7.x86_64.rpm
ignore dependencies
[root@xuegod72 Packages]# rpm -ivh mariadb-server-5.5.44-2.el7.x86_64.rpm --nodeps
The third type: go to the rpm package related website to download Software package
http://rpmfind.net/
http://rpm.pbone.net/
http://www.rpmseek.com/index.html

rpm query function
usage: rpm –q is often used in combination with the following parameters
 -a Query all installed packages
 -f Query the package to which the file belongs
 -i Display installed rpm package information
 Use with p to display the related file list and information of the uninstalled package
Usually can be used with pipes | more to use to make the results more readable

[root@xuegod72 Packages]# rpm -q lrzsz #find
[root@xuegod72 Packages]# rpm -qi lrzsz #Display information that lrzsz has been installed
[root@xuegod72 Packages]# rpm -qf `which vim`
[root@xuegod72 Packages]# rpm -ql zsh|more #Check that zsh is installed Those files

rpm package uninstallation
usage: rpm -e package name
Parameters :
--nodeps ignore dependencies
[root@xuegod72 Packages]# rpm -e mariadb-5.5.44.el7.x86_64 --nodeps

signature verification
After importing RPM-GPG-KEY , When installing the rpm package, verify the rpm signature
The application of GPG on Linux is mainly to realize the signature mechanism of the officially released package.
GPG is divided into public key and private key.
Public key: As the name implies, a key that can be shared, mainly used to verify the data encrypted by the private key and the data to be sent to the private key party with the signature.
Private key: a key reserved locally, used to sign local data and verify data signed with the public key
Example an RPM package
[root@xuegod72 Packages]# rpm --import /etc/pki/rpm-gpg /RPM-GPG-KEY-redhat-release
[root@xuegod72 Packages]# rpm -K lrzsz-0.12.20-36.el7.x86_64.rpm


2.yum installation package
yum (full name Yellow dog Updater, Modified) is a front-end package manager. Based on RPM package management, it can automatically download and install RPM packages from a specified server, and can automatically handle dependencies, and install all dependent software packages at one time, without the need to download and install tediously again and again. yum provides commands to find, install, delete one, a group or even all software packages, and the commands are concise and easy to remember.

YUM: Solve dependency problems and download software packages automatically. It is based on the C/S architecture
C=client S =ftp\http\file

YUM source is divided into local source and network source.

Local
yum source configuration [root@xuegod72 ~]# rm -rf /etc/yum.repos.d/*
[root@xuegod72 yum.repos.d]# vim rhel7.repo
[7-source] #yum source name, unique, used to distinguish different yum sources
name=rhel7-server #Description of yum source information
baseurl=file:///media #path of yum source (repodata directory The directory where it is located)
enabled=1 # is 1, indicating that the yum source is enabled
gpgcheck=0 # is 1, use the public key to verify the correctness of the rpm

Clear yum cache
[root@xuegod72 yum.repos.d]# yum clean all

Generate a list
[ root@xuegod72 ~]# yum list|more
A few minor issues:
 Determine whether the CD is linked
 Whether the CD is mounted
 Whether the format in the configuration file is correct, and whether the letters and symbols are not written

yum Use
1) Install yum install -y
2) Check and upgrade yum check-update
3) Upgrade yum update
4) Software Package query yum list
5) Package information yum info
6) Uninstall yum remove
7) Help yum -help, man yum
[root@xuegod72 ~]# yum -y install httpd

install a set of packages
to see which package groups
[root@ xuegod72 ~]# yum grouplist

installs a package group
[root@xuegod72 ~]# yum –y groupinstall "Security Tools"

3. Source code compilation and installation package installation
of source code package
1) Unzip and unpack
tar -xzvf source code package
[Description ]
x is for unpacking, z is for decompression (only for gzip, bz2 [use j] to unpack first and then unzip to decompress), v to display the process, f to specify the name of the decompressed package
2) Configuration
Enter the decompressed directory and use ./configure [--prefix=/usr/local/filname] to configure. This process is mainly to collect system information, set the installation directory, etc. (you only need to delete this directory when uninstalling)
3) Compile
make -j 4
4) Install
make install

nginx Installation and
installation dependencies
Check if these two packages are available: pcre-devel zlib-devel
[root@xuegod72 mnt]# yum -y install zlib-devel
[root@xuegod72 mnt ]# yum -y install pcre-devel

add running user
[root@xuegod72 mnt]# useradd -s /sbin/nologin -M nginx
parameter explanation
 -M does not create a host directory
 -s specifies the shell environment for login /sbin/nologin Forbid login

Unzip
nginx [root@xuegod72 mnt]# tar -zxvf nginx-1.0.15.tar.gz
[root@xuegod72 mnt]# tar -zxvf nginx-1.0.15.tar.gz -C /usr/local
[root @xuegod72 mnt]# ls /usr/local
[root@xuegod72 mnt]# cd /usr/local/nginx-1.0.15
[root@xuegod72 nginx-1.0.15]# ./configure --prefix=/usr/local/nginx --user=nginx --group =nginx

If the above situation occurs, the gcc package is missing, install it
[root@xuegod72 nginx-1.0.15]# yum install -y gcc # Execute ./configure

[root@xuegod72 nginx-1.0.15]# make -j 4
[root@xuegod72 nginx-1.0.15]# make install


nginx path optimization
First copy the main program to etc.
[root@xuegod72 ~]# cd /usr/local/nginx/sbin/
[root@xuegod72 sbin]# ls
nginx
[root@xuegod72 sbin]# cp nginx /etc/init.d/
Verify that there are no syntax errors
[root@xuegod72 sbin]# /etc/init.d/nginx -t
nginx: the configuration file /usr/local/nginx /conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
Start nginx without parameters, verify

[root@xuegod72 sbin]# /etc/init.d/nginx
[root@xuegod72 sbin]# netstat -anput|grep nginx

Guess you like

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