Comprehension of the road (two) Centos7 of: linux software installation summary

linux software installation summary

Linux system software, "four" types of mounting principle Comments: source packages installed, RPM binary installation, YUM-line installation, the installation script package

A, Linux software package classification

1.1 source package

Advantages:

  1. Open, if there is sufficient capacity, can modify the source code ;
  2. Free to choose the desired function;
  3. Software installation is compiled, it is more suited to their system, more stable, more efficient;
  4. Easy to uninstall;

Disadvantages :

  1. The installation process step more, especially when installing large software collections (such as LAMPenvironmental structures), prone to spelling mistakes;
  2. Longer compilation time, installation time is longer than the binary installation;
  3. Because it is compiled and installed, the installation process once a novice error is difficult to solve;

Note:
** requirements for efficient software to install source package version, because this is a compilation machine, more compatibility and efficiency, while ** rpmpackage is the public version of the software developers can be used to not pay attention to the efficiency of the application.

1.2 binary packages ( RPMpackage)

Advantages:

  1. Package management system is simple, can be achieved only installation packages, upgrade, query, and unload a few commands;
  2. Installation speed faster than the source package installation;

Disadvantages:

  1. After compilation, you can no longer see the source code;
  2. Source Package function selection is better flexibility;
  3. Dependence;

1.3 yum install online

Can easily solve RPMinstallation dependencies, a command can help users from the Internet (local can) find the installation package for installation.

Note:RedHat The yumis fee-based services, and CentOSthe yumfree service.

1.4 Script installation package

The so-called script installation packages such as: lnmp/lamp LNMP a key installation package is the package installation process complex written script , beginners can execute the script achieve a key installation. But the actual installation or源码包和二进制包 .

** Pros: ** Installation is simple and quick;

** Cons: ** completely lost customizable;

to sum up:

In fact, Linuxthe package only source packages and binary (RPM) package two software installation package.

Second, the source package is installed ( the recommended way )

2.1 source package with RPM packages the difference

Before installation of the difference: difference conceptual
distinction after installation: different mounting positions

clipboard.png

The effects of different mounting positions brought 2.2

2.2.1 rpm package mounting position

rpmPackage installed service using the service management system can command ( service) to manage,
for example: RPMpackages installed apachestartup method is:

/etc/rc.d/init.d/httpd start
service httpd start

Please note: Therpm package installation is also possible to specify the location of the installation, servicethe command is redhata unique command, it /etc/rc.d/init.d/XXXX startis the most standard start-up mode. If rpminstallation directory is specified package, sorry, two methods can be used not start.

2.2.2 Source Package mounting position

Installed in the specified position which, generally:

/usr/local/软件名/

Source package installation services, can only be managed services with absolute path.

2.2.3 summary

  1. Source package can not use [ service] command to start the service because the source packages installation location specified by the user, on which are not uniform. And after the rpm package, usually on the [ /etc/rc.d/init.d] directory, and [ servicewhen] command is executed, it will automatically search for the directory, so the rpmpackage installation services enable [ service] command.
  2. In summary, the different installation location, start method is different.
  3. The method of using an absolute path to the boot procedure is common, usually the package will be written on the method of starting the program.
  4. If you start the program after installation to copy the source package [to /etc/rc.d/init.d] directory, you also can use [ service] command execution.
  5. Source package sure to specify the installation directory, not specified, and will be rpmthe same as the installed everywhere. However, it can not be -euninstalled. Is generally designated directory /usr/local(can be seen Windowsin Program Files). Meanwhile, the source packages can not use servicethe command to start, because servicethe command search /etc/rc.d/init.d/directory to start the service.

2.3 Source Package Installation Procedure ( Key )

clipboard.png

2.3.1 installed and ready to get source packages

  1. Because the source code is cwritten in, so you must install cthe language compiler:gcc
  2. From the official website to download the source package, if it is downloaded to the windowsabove, you can use the winSCPspread linuxon

Note: If you have installed the binary packages, the source package is installed can continue, because the two are not the same installation directory. However, it is not recommended, because the port conflict.

clipboard.png

2.3.2 Details of source package installation process

The following case study to install apache2

2.3.2.1 ensure that gccthe compiler

gcc -v # 是否能打印你使用gcc版本信息

2.3.2.2 download source, extract

http://mirror.bit.edu.cn/apache/httpd/

By winSCPdragging /local/usr/srcsave directory

Decompression: tar -zvxf httpd-2.2.31.tar.gzdirectory after decompression is [ httpd-2.2.31]

2.3.2.3 Installation

Must enter the installation directory of the unzipped in the [httpd-2.2.31]

A mounting step, performed [ ./configure] command, which is used to check the software configuration (for each source packet will have substantially the command, even if the individual is not the command, will also provide an alternative command), which has the following Features:

  • Defined options needed;
  • Detection system environments meet the installation requirements;
  • The first term defined options and the second information detection items are written to the system environment Makefilefiles for subsequent editing. (Subsequent [ make] and [ make install] will be dependent on the command file)

[Run ./configure --prefix=/usr/local/apache2] This command is used to specify the installation location is: [ /usr/local/apache2] ([which apache2] do not need to create a directory in advance, [ make install] will be created automatically when the command is executed). After the command is executed, it will generate in the current directory Makefilefiles.

Check the library dependencies:make depend

Step two to install, execute [ make] command, the compiler source code (this step is usually time-consuming)

Installation Step three, execute [ make install] command, the installer will create [this time /usr/local/apache2] directory

2.3.2.4 Tips

  1. If the termination occurs during the execution of the command, and the emergence error、warnor noprompt, it indicates an error. Otherwise, everything is normal.
  2. If the execution [ ./configure] or [ make] command when an error occurs, you do not need to delete [ /usr/local/apache2] directory, because the program has not really installed. Only need to perform [ make clean] to command, the command is used to clear the cache, temporary files, etc., to restore the installation environment is not installed state.
  3. If the [Executive make installbeing given] command, you need to delete [ /usr/local/apache2] directory and execute [ make clean] command job.

Three, RPM management command

Source 3.1 RPM package

All RPMpackages are in the system CD in the Packagesdirectory

3.2 RPM Package Naming

Package name - software version - the number of software releases - suitable Linuxplatform - suitable hardware platform - the extension package

httpd-2.2.15-15.el6.centsos.1.i686.rpm

httpdPackage name -2.2.15software version -15number released -el6.centosfor the Linuxplatform -i686to adapt to the hardware platform -rpmpackage extension, el6is redhatthe Enterprise Edition

3.3 RPM package dependencies

. A dependency tree: a->b->cSolution: from the back mounting
b annular dependency: a->b->c->aSolution: can be mounted on a command
c module dependency: dependence library, the library also called modules, is linuxamong the functions, it there is a typical feature, is to [ .so.数字end], it relies on the fact that a file instead of the package. The file hiding them in one package. As long as we on the package installation files, the file also installed. Workaround: Log www.rpmfind.netwebsite, enter the name of the query library file to the corresponding rpmpackage, then install it.

yum-line installation can easily resolve dependencies, a command can help users from the Internet (also local) find the installation package for installation.

Note:RedHat The yumis fee-based services, and CentOSthe yumfree service.

3.4 RPM installation

clipboard.png

rpm -ivh package full name

-i(install) 安装; -v(verbose) 详细信息; -h(hash) 进度;

3.5 RPM upgrade and uninstall

Upgrade command

rpm -Uvh Package full name (to be upgraded to software version), if there is no version of the software is installed, this command can be used instead rpm -ivh.

Uninstall command

rpm -e 包名(比如Httpd,不需要包全名)

This command is different from the installation and upgrade, it can run in any directory, the principle is to /var/lib/rpmcatalog the database (such as __db0) find the corresponding package (rpm packages are already installed in these databases), and then uninstall.
--nodepsWhether this option when you install and uninstall, are not the best use.

rpmLocation installation package is determined by the developer of the package, the location of the installation will be very messy, so it is best to use rpm -ea command to uninstall.

With respect to a binary installation, the installation source is specified installation directory, and uninstall when you need only delete the corresponding directory can be completely uninstalled without leaving a residue.

3.6 RPM package query

3.6.1. Query whether the installation

rpm -q  包名

rpm -qa 
# q ==> query  a ==> all

Query all installed RPM package

 rpm -qa | grep httpd 

grep followed by regular expressions, find followed by a wildcard

3.6.2. Details of package query

rpm -qi 包名
rpm -qip 包全名

# i ==> infomation

# p ==> package : 查询**`未安装包`**信息

Sometimes encounter problems, according to the website can be queried data package is not installed in the information provided

3.6.3. Query package file installation location

rpm -ql 包名

# l ==> list
# -p ==> package : 查询未安装包信息

Package authors wishing to view the location of the installation package

RPM package default installation location

clipboard.png

3.6.4. Query system files belong to which RPM package

rpm -qf 系统文件名
# f ==> file : 查询系统文件属于哪个软件包

The file must be through the RPMpackage installation

3.6.5. Query package dependencies

rpm -qR 包名

R ==> requires : 查询软件包的依赖性 
p ==> package : 查询未安装包的信息

3.7 RPM 包校验

 rpm -V 已安装的包名

-V ==> (verify) : 校验指定RPM包中的文件

执行 rpm -V httpd 后, 无任何提示, 代表该文件没有被做任何修改

​ 判断本地的apache 与官方给出的是否一致, 从而判断是否被人修改。

​ 修改文件 /etc/httpd/conf/httpd.conf , 在注释行添加任意内容后, 再次执行
提示 : S.5…T. c /etc/httpd/conf/httpd.conf

验证内容中的8个信息:

S: 文件大小是否改变
M: 文件的类型或文件的权限( rwx )是否被改变
5: 文件MD5 校验和是否改变( 可以看成文件内容是否改变 )
D: 设备的主从代码是否改变
L: 文件路径是否改变
U: 文件的属主( 所有者 ) 是否改变
G: 文件的属组是否改变
T: 文件的修改时间是否改变

验证内容中的文件类型:

c(config file) : 配置文件
d(documentation) : 普通文档
g(ghost file) : "鬼"文件, 很少见, 就是该文件不应该被这个RPM包包含
L(license file) : 授权文件
r(read me) : 描述文件
MD5校验

作用:
​ 用来校验文件的完整性(文件内容是否被改变)。

​ 例如, 在官网下载的游戏, 官方会给出MD5校验码, 将下载的游戏通过专用的MD5校验工具校验后生成一份MD5校验码, 对比两份校验码是否一致, 不一致则说明,下载的文件可能丢包, 可能文件损坏, 可能被其他人动过手脚一直木马等。

四、yum在线安装

4.1 yum源文件

yum的优点:
​ 将所有软件包放到官方服务器上,当进行yum在线安装时,可以自动解决依赖性问题。(rpm缺点:安装过程中,rpm包依赖性太强)。

redhatyum在线安装需要付费,CentOS不需要。

​ 在【/etc/yum.repos.d/】目录中,默认有4yum源文件,其中【CentOS-Base.repo】是基本yum源文件,如果我们能上网,那它是默认生效的,而其他的都是默认不生效的。

clipboard.png

4.2 yum命令

  1. 查询
    yun list --查询所有可用软件包列表
    yum search 关键字 --搜索服务器上所有和关键字相关的包

  2. 安装

    yum -y install 包名 (-y 自动回答yes)
    yum安装只写包名即可! eg:yum -y install gcc --c语言编译器

  3. 升级/卸载

升级:yum -y update 包名

-update:升级;
-y:自动回答yes;

卸载:yum -y remove 包名

-remove:卸载;
-y:自动回答yes;

!!!服务器使用最小化安装,用什么软件安装什么,尽量不要卸载!!!

​ ①LANG=en_US:切换至英文;(临时生效)
​ ②LANG=zh_CN.utf8:切换至中文;(临时生效)

五、脚本安装

5.1 脚本安装包

​ 所谓的脚本安装包如:lnmp/lamp LNMP一键安装包,就是把复杂的软件包安装过程写成了程序脚本,初学者可以执行脚本实现一键安装。但实际安装的还是源码包和二进制包

​ **优点:**加单,快速,方便
缺点:

1.不能定义安装软件的版本;
2.不能定义所需要的软件功能;
3.源码包的优势几乎完全丧失;

5.2 脚本安装包:准备工作

​ 1、本节以安装LNMP1.0为例,所以需要先停止之前安装的apachemysql服务(最好也将源码包安装的apache/usr/local/apache2】删除)

nignx非常优秀,可以支持更大的并发量。apache的默认并发量是400,如果给它改大,比如到> 2000,就要测一测了,如果稳定才能再继续增加。nginx不用测试就可以设置到50000(用户同一时刻刷新网页)。可以说一台nignx服务器顶3apache

​ 2、保证yum源正常:可以使用【yum list】命令测试。(若是光盘yum源,记得挂载光盘)
​ 3、关闭SELinux和防火墙:

a、永久关闭SELinux的方法:编辑文件【/etc/selinux/config】,将【SELINUX=enforcing】改为【SELINUX=disabled】,然后重启系统即可。
b、永久关闭防火墙的方法:【chkconfig iptables off】,开启为:【chkconfig iptables on】;临时关闭防火墙的方法:【service iptables stop】,开启为:【service iptables start】。

​ 4、脚本安装过程中,会将系统中已有的apache、mysql、php等卸载掉。下面是安装脚本【centOS.sh】的部分内容:
…部分内容省略…

yum install -y ntp
ntpdate -u pool.ntp.org
date

rpm -qa|grep httpd
rpm -e httpd
rpm -qa|grep mysql
rpm -e mysql
rpm -qa|grep php
rpm -e php

yum -y remove httpd*
yum -y remove php*
yum -y remove mysql-server mysql
yum -y remove php-mysql

​ …部分内容省略…
​ **注:**安装后,如果安装卡在了【php-fpm】那里,通常表示已安装成功,只是【php-fpm】那里卡住了(物理机少见,但虚拟机比较常见),解决的方法就是:使用命令【pkill -9 php-fpm】杀掉【php-fpm】进程,然后重新启动该进程【/etc/rc.d/init.d/php-fpm start】即可。

LNMP一键安装包安装地址

mysql
rpm -e mysql
rpm -qa|grep php
rpm -e php

yum -y remove httpd*
yum -y remove php*
yum -y remove mysql-server mysql
yum -y remove php-mysql


​    ......部分内容省略......
​    **注:**安装后,如果安装卡在了【`php-fpm`】那里,通常表示已安装成功,只是【`php-fpm`】那里卡住了(物理机少见,但虚拟机比较常见),解决的方法就是:使用命令【`pkill -9 php-fpm`】杀掉【`php-fpm`】进程,然后重新启动该进程【`/etc/rc.d/init.d/php-fpm start`】即可。

### [LNMP一键安装包安装地址](https://lnmp.org/install.html)

 

注意:转发网址:https://segmentfault.com/a/1190000011325357
Published 35 original articles · won praise 4 · Views 1061

Guess you like

Origin blog.csdn.net/qq_41980405/article/details/102097488