The "four" installation principle of software in Linux system is detailed: Source package installation, RPM binary installation, yum online installation, script installation package one, Linux package Classification 1.1 source Package
Advantages:
- Open source, if there is sufficient capacity
可以修改源代码
;
- You can freely choose the function you want;
- Software is compiled and installed, so more suitable for their own system, more stable, more efficient;
- Easy to uninstall;
Disadvantages :
- Installation process more steps, especially when installing a large set of software (such as
LAMP
environmental construction), prone to spelling errors;
- The compilation process takes a long time, the installation is longer than the binary installation time;
- Because it is compiled and installed, the installation process when the novice error is difficult to solve;
Note:
对于要求效率的软件,要安装源码包版本,因为是本机编译,更具有兼容性和效率,
The rpm
package is a popular version provided by software developers and can be used for applications that do not focus on efficiency.
1.2 Binary Package (
RPM
Package
Advantages:
- Package management system is simple, only a few commands can be implemented to install, upgrade, query and uninstall;
- Installation speed is much faster than the source package installation;
Disadvantages:
- After compiling, you can no longer see the source code;
- function selection is not as flexible as the source package;
- Dependence
1.3 Yum Online Installation
can easily solve the RPM
installation of dependent files, a command can help users from the Internet (local can also) find the installation package for installation.
Note: RedHat
yum
is the charge service, and CentOS
the yum
free service.
1.4 Script Installation Package
The so-called script installation package, such as: lnmp/lamp
LNMP One-click installation package, is the complex package installation process written as a program script , beginners can execute a script implementation of one-click installation. But the actual installation is still 源码包和二进制包
.
Advantages: easy and quick installation;
Cons: complete loss of customization;
Summary:
Linux
in fact in the 源码包
package 二进制(RPM)包
only and two kinds of software installation package.
Second, the source package installation (
Recommended Way) 2.1 Source package differs from RPM package
differences before installation: conceptual differences
The difference after installation: different installation locations
2.2 Impact of different mounting positions 2.2.1 RPM Package Installation location
rpm
Package-Installed services can be managed using the System Service Management Command ( service
),
For example, the RPM
boot method for package installation apache
is:
/etc/rc.d/init.d/httpd startservice httpd start
Please note: rpm
Package installation can also specify the installation location, service
command is a redhat
proprietary command, so /etc/rc.d/init.d/XXXX start
is the most standard way to start. If the rpm
installation directory is specified for the package, I am sorry, the two boot methods are not available.
2.2.2 Source Package Installation Location
Installed in the specified location, the general is:
/usr/local/软件名/
The source code package installs the service, can only use 绝对路径
carries on the service the management.
2.2.3 Summary
- The source package is not able to use the "
service
" command to start the service, because the source package installation location is specified by the user, where is not unified. When the RPM package is installed, it is usually placed in the " /etc/rc.d/init.d
" directory, and when the " service
" command executes, the directory is automatically searched, so the rpm
package-installed service can make the " service
" command.
- In summary, the installation location is different, the starting method is a difference.
- The method of starting a program with an absolute path is generic, and the method of starting the program is usually written in the package.
- If you copy the boot program after the source package is installed to the
/etc/rc.d/init.d
directory, you can also use the service
command to execute.
- Source package must specify the installation directory, if not specified, will be
rpm
installed and the same everywhere. However, you cannot -e
uninstall it. The general specified directory is /usr/local
(as you can see Windows
Program Files
). At the same time, the source package cannot be started with a service
command, because the service
command is /etc/rc.d/init.d/
to search the directory to start the service.
2.3 Source Package Installation Steps (
重点
)
2.3.1 Installation Preparation and source package acquisition
- Since the source code is
c
written in language, the language compiler should be installed first c
:gcc
- Download the source package from the official website, if downloaded to the
windows
above, you can use the winSCP
upload linux
to the
Note: If a binary package is already installed, the source package can continue to install because the installation directory is different. However, this is not recommended because the port will conflict.
2.3.2 Source Package installation Detailed procedure
The following apache2
is an example of installation
2.3.2.1 ensure that there is
gcc
Compiler
gcc -v # 是否能打印你使用gcc版本信息
2.3.2.2 Download source package, unzip
http://mirror.bit.edu.cn/apache/httpd/
winSCP
Save with Drag to /local/usr/src
directory
Unzip: tar -zvxf httpd-2.2.31.tar.gz
"" After the extracted directory httpd-2.2.31
2.3.2.3 Installation
installation must be entered into the extracted directory " httpd-2.2.31
"
installation Steps 一
, execute the command, which is ./configure
used for software configuration and inspection (basically each source package will have the command, even if the individual does not have the command, will also provide the relevant alternative command), it has the following features:
- Define the required feature options;
- Check whether the system environment meets the installation requirements;
- Write the function options defined in the first item and the information for the detection system environment in the second item to the
Makefile
file for subsequent edits. (subsequent " make
and" make install
commands will depend on the file.)
Executes the command "", which specifies that the ./configure --prefix=/usr/local/apache2
installation location is: " /usr/local/apache2
", where the apache2
directory does not need to be created in advance, and is make install
created automatically when the command executes. After the command executes, the file is generated in the current directory Makefile
.
Check the dependent libraries:make depend
Install step 二
, execute " make
" command, compile the source code (this step is usually time-consuming)
Install the 三
procedure, execute the make install
command, install the program, and create the /usr/local/apache2
directory
2.3.2.4
Tips
- If a termination occurs during the execution of the command, and the occurrence
error、warn
or no
prompt indicates an error, otherwise, everything is fine.
- If there is an error executing the "or" command, you
./configure
make
do not need to delete the " /usr/local/apache2
" directory because the program is not actually installed. Just execute the make clean
command, which clears the cache, temporary files, and so on, and restores the installation environment to the non-installed state.
- If the "
make install
" command times are wrong, you need to delete the " /usr/local/apache2
" "Directory and Execute the" make clean
"command.
Third, rpm command Management 3.1 RPM package source
All RPM
packages are in 系统光盘
the Packages
directory
3.2 RPM Package naming rules
Package Name-software version-number of software releases-suitable
Linux
platform-suitable hardware platform-package extension
httpd-2.2.15-15.el6.centsos.1.i686.rpm
httpd
Package name -2.2.15
software version -15
released the number of times appropriate for the -el6.centos
Linux
platform -i686
adaptation of the hardware platform -rpm
package extension, el6
is redhat
the Enterprise Edition
3.3 RPM Packet Dependency
A. Tree-based dependency: a->b->c
Workaround: Install from the rear
B. Ring a->b->c->a
-based dependency: Workaround: Install in one command
C. module dependencies: library file dependencies, library also called module, is linux
the function, it has a typical feature, is " .so.数字
" end, it depends on is actually a file, not a package. This file is hidden in one package. We simply install the package on which the file is located and the file is installed. Workaround: Log www.rpmfind.net
into the Web site, enter the library file name query to the corresponding rpm
package, and then install.
yum
Online installation can easily solve the dependent files, a command can help users from the Internet (local can also) find the installation package for installation.
Note: RedHat
yum
is the charge service, and CentOS
the yum
free service.
3.4 RPM Installation
RPM-IVH Package Full name
-i(install) 安装; -v(verbose) 详细信息; -h(hash) 进度;
3.5 RPM Upgrade and uninstallation
Upgrade Command
The
rpm -Uvh
full name of the package (the version of the software to be upgraded to), if no version of the software is installed, this command can be replaced
rpm -ivh
.
Uninstall Command
-e 包名(比如Httpd,不需要包全名)
This command is different from the installation and upgrade, it can be run in any directory, the principle is to go to the /var/lib/rpm
directory in the database (such as __db0
) to find the corresponding package (the RPM package has been installed in these databases), and then uninstall.
--nodeps
This option is best not to use when installing or uninstalling.
The location of the installation
rpm
package is determined by the package developer, and the location after installation is very messy, so it is best to use the
rpm -e
command to uninstall.
Relative to the binary installation, the source installation is the specified installation directory, uninstall only need to delete the corresponding directory can be completely uninstalled, do not leave a little residue.
3.6 RPM Package Query 1. Whether the query is installed
rpm -q 包名rpm -qa # q ==> query a ==> all
Query all installed RPM packages
rpm -qa | grep httpd
grep followed by a regular expression, find followed by a wildcard character
2. Query Package Details
rpm -qi 包名rpm -qip 包全名# i ==> infomation# p ==> package : 查询**`未安装包`**信息
Sometimes problems can be queried according to the website provided in the package information is not installed
3. Query the file installation location in the package
rpm -ql 包名# l ==> list# -p ==> package : 查询未安装包信息
To see where the package author wants to install the package
RPM Package default installation location
4. Which RPM package does the query system file belong to?
rpm -qf 系统文件名# f ==> file : 查询系统文件属于哪个软件包
The file must be RPM
installed through the package
5. Querying the dependencies of a package
package : 查询未安装包的信息
3.7 RPM Package Check
rpm -V 已安装的包名-V ==> (verify) : 校验指定RPM包中的文件
After executing rpm-v httpd, there is no prompt to represent that the file has not been made any modifications
Judge whether the local is apache
consistent with the official given, so as to determine if the person has been modified.
Modify the file /etc/httpd/conf/httpd.conf
, add any content to the comment line, and then execute the
Tips: S.5 .... T. c/etc/httpd/conf/httpd.conf
Verify the 8 information in the content:
S: 文件大小是否改变M: 文件的类型或文件的权限( rwx )是否被改变5: 文件MD5 校验和是否改变( 可以看成文件内容是否改变 )D: 设备的主从代码是否改变L: 文件路径是否改变U: 文件的属主( 所有者 ) 是否改变G: 文件的属组是否改变T: 文件的修改时间是否改变
Verify the file types in the content:
c(config file) : 配置文件d(documentation) : 普通文档g(ghost file) : "鬼"文件, 很少见, 就是该文件不应该被这个RPM包包含L(license file) : 授权文件r(read me) : 描述文件MD5校验
function:
Used to verify the integrity of the file (if the contents of the file have been changed).
For example, in the official website to download the game, the government will give a MD5
check code, the download of the game through a dedicated verification MD5
tool to generate a MD5
check code, compared to two check code is consistent, inconsistent is that the downloaded file may be lost, possibly file corruption, May have been moved by other people have been the Trojan horse and so on.
Iv. Yum Install 4.1 yum source file online
Benefits of Yum:
Put all packages on the official server, when yum
online 自动解决依赖性问题
installation is possible. (rpm Disadvantage : rpm
package dependencies are too strong during installation).
redhat
yum
Online installation requires a fee,
CentOS
not required.
In the " /etc/yum.repos.d/
" directory, there is 4
a default yum
source file, where " CentOS-Base.repo
" is the basic yum
source file, if we can access the Internet, it is the default, and the other is not in effect by default.
4.2 Yum Command
- Inquire
yun list
--Query all available packages list
yum search
Keywords--Search all the keywords related to the server
- Installation
yum -y install
Package name ( -y
Auto Answer yes
)
yum
Install write-only package name! eg:yum -y install gcc
--c Language Compiler
- Upgrade/Uninstall
Upgrade:yum -y update 包名
-update:升级;-y:自动回答yes;
Uninstall:yum -y remove 包名
-remove:卸载;-y:自动回答yes;
!!!服务器使用最小化安装,用什么软件安装什么,尽量不要卸载!!!
①lang=en_us: Switch to English; (Temporary entry into force)
②lang=zh_cn.utf8: Switch to Chinese; (Temporary effect)
V. Script Installation 5.1 script installation package
The so-called script installation package, such as: lnmp/lamp
LNMP One-click installation package, is the complex package installation process written as a program script , beginners can execute a script implementation of one-click installation. But the actual installation is still 源码包和二进制包
.
Advantages: single, fast, convenient
Disadvantages:
1.不能定义安装软件的版本;2.不能定义所需要的软件功能;3.源码包的优势几乎完全丧失;
5.2 Script installation package: Preparing for work
1, this section to install LNMP1.0
as an example, so you need to stop the previous installation apache
and mysql
service (preferably also the source package installed apache
" /usr/local/apache2
" "delete)
nignx
very good, can support a larger concurrency volume.
apache
The default concurrency is
400
that if it is changed, for example to >
2000
, it will be measured, if stability can continue to increase. Nginx can be set without testing
50000
(users refresh the page at the same time). Can be said to a server on the top of the
nignx
3
table
apache
.
2, ensure that yum
the source is normal: You can use the " yum list
" command test. (If yum
the CD source, remember to mount the CD-ROM)
3. Shutdown SELinux
and firewall:
a、永久关闭SELinux的方法:编辑文件【/etc/selinux/config】,将【SELINUX=enforcing】改为【SELINUX=disabled】,然后重启系统即可。b、永久关闭防火墙的方法:【chkconfig iptables off】,开启为:【chkconfig iptables on】;临时关闭防火墙的方法:【service iptables stop】,开启为:【service iptables start】。
4, the script installation process, will be existing in the system apache、mysql、php
and so on uninstall off. Here is a section of the installation script " centOS.sh
":
...... Part of the content omitted ...
yum install-y ntpntpdate-u pool.ntp.orgdaterpm-qa| grep httpdrpm-e httpdrpm-qa| grep mysqlrpm-e mysqlrpm-qa| grep phprpm-e phpyum-y remove Httpd*yum-y remove php*yum-y Span class= "hljs-built_in" >remove mysql-server mysqlyum-y Remove Php-mysql
...... Part of the content omitted ...
Note: after installation, if the installation card is " php-fpm
" there, it usually means that the installation is successful, just " php-fpm
" there is stuck (the physical machine is rare, but the virtual machine is more common), the solution is to use the command "Kill" " pkill -9 php-fpm
php-fpm
process, Then restart the process " /etc/rc.d/init.d/php-fpm start
".
LNMP One-click installation package Installation Address
Note: Forwarding URL: 1190000011325357
Summary of Linux Software installation methods