rpm二进制包-----》已经使用了GCC编译后,可以直接安装的rpm包
tar源码包---------》需要进行编译后,才可以进行安装的软件包 比如:.src.rpm
1、rpm包的获取方式
Centos系统镜像光盘、网站rpmfind.net、软件包的官方网站(mysql、nginx等)
2、rpm包格式说明
zsh - 5 . 0 . 2- 28. el7. x86_64 .rpm
报名 主版本号 此版本号 修订的次数 发布的次数 Centos7 x86平台64位系统 后缀名
修订指的是第几次修改bug,发布指的是第几次发布(修改安装路径,默认参数等操作)
3、rpm包的两种安装方式
第一种:本地安装
[root@xuegod140 Packages]# rpm -ivh zsh-5.0.2-28.el7.x86_64.rpm
warning: zsh-5.0.2-28.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing… ################################# [100%]
Updating / installing…
1:zsh-5.0.2-28.el7 ################################# [100%]
第二种:网络安装,安装epel扩展源
[root@xuegod140 ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Retrieving http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
warning: /var/tmp/rpm-tmp.L05Xl2: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Preparing… ################################# [100%]
Updating / installing…
1:epel-release-7-11 ################################# [100%]
[root@xuegod140 ~]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
epel/x86_64/metalink | 7.8 kB 00:00:00
*epel: mirror01.idc.hinet.net
epel | 4.7 kB 00:00:00
(1/3): epel/x86_64/group_gz | 88 kB 00:00:01
(2/3): epel/x86_64/primary_db | 6.6 MB 00:00:02
(3/3): epel/x86_64/updateinfo | 1.0 MB 00:00:03
repo id repo name status
CentOS7 CentOS7-server 3,971
epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 13,018
repolist: 16,989
4、rpm软件包安装后的默认目录
rpm包安装完毕后,默认文件都存放在/var/lib/rpm/目录下,通过在进行查询rpm包的时候,就会到这个目录进行搜索是否已经安装过rpm包这个命令。
5、rpm命令(查询、安装、卸载、升级、校验)
参数:
例:
(1)查询httpd是否已经安装
[root@xuegod140 Packages]# rpm -qa httpd
[root@xuegod140 Packages]# #没有输出软件包的信息,就说明没有安装
[root@xuegod140 Packages]# rpm -qa lrzsz
lrzsz-0.12.20-36.el7.x86_64 #安装了lrzsz命令,就可以输出包的全名
[root@xuegod140 Packages]# rpm -qa | grep lrzsz
lrzsz-0.12.20-36.el7.x86_64 #通过过滤命令也可以查询是否安装
(2)查询已安装软件包的全名
[root@xuegod140 ~]# rpm -qf /usr/bin/ls #-qf后面需要跟上命令的文件
coreutils-8.22-21.el7.x86_64
(3)查询已安装软件包的安装位置
rpm -qi zsh
Name : zsh
Version : 5.0.2
Release : 28.el7
Architecture: x86_64
Install Date: Fri 29 Mar 2019 11:52:01 AM CST
Group : System Environment/Shells
Size : 5855982
License : MIT
Signature : RSA/SHA256, Fri 11 Aug 2017 04:28:17 AM CST, Key ID 24c6a8a7f4a80eb5
Source RPM : zsh-5.0.2-28.el7.src.rpm
Build Date : Wed 02 Aug 2017 06:52:37 PM CST
Build Host : c1bm.rdu2.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem http://bugs.centos.org
Vendor : CentOS
URL : http://zsh.sourceforge.net/
Summary : Powerful interactive shell
Description :
The zsh shell is a command interpreter usable as an interactive login
shell and as a shell script command processor. Zsh resembles the ksh
shell (the Korn shell), but includes many enhancements. Zsh supports
command line editing, built-in spelling correction, programmable
command completion, shell functions (with autoloading), a history
mechanism, and more.
(4)查询已安装文件的会生成那些文件
[root@xuegod140 Packages]# rpm -ql zsh | grep bin
/bin/zsh
/usr/share/zsh/5.0.2/functions/_bind_addresses
/usr/share/zsh/5.0.2/functions/_bindkey
/usr/share/zsh/5.0.2/functions/_combination
一般安装的软件包会将一些文件存放在固定目录如下:
/etc 配置文件
/bin /sbin 可执行文件
/lib /lib64 库文件
/usr/include 头文件
/usr/share/doc 使用手册帮助文件
/usr/share/man man手册
(5)查询未安装软件包的相关信息
[root@xuegod140 Packages]# rpm -qpl httpd-2.4.6-80.el7.centos.x86_64.rpm | grep bin | more #过滤bin到more下显示
warning: httpd-2.4.6-80.el7.centos.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
/usr/sbin/apachectl
/usr/sbin/fcgistarter
/usr/sbin/htcacheclean
/usr/sbin/httpd
/usr/sbin/rotatelogs
/usr/sbin/suexec
/usr/share/httpd/icons/binary.gif
/usr/share/httpd/icons/binary.png
/usr/share/httpd/icons/binhex.gif
/usr/share/httpd/icons/binhex.png
/usr/share/httpd/icons/small/binary.gif
/usr/share/httpd/icons/small/binary.png
/usr/share/httpd/icons/small/binhex.gif
/usr/share/httpd/icons/small/binhex.png
/var/www/cgi-bin
(6)查询软件包的依赖性
两种方式:
第一种:rpm -qpR 包的全名
[root@xuegod140 Packages]# rpm -qpR httpd-2.4.6-80.el7.centos.x86_64.rpm | more
warning: httpd-2.4.6-80.el7.centos.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
/etc/mime.types
system-logos >= 7.92.1-1
httpd-tools = 2.4.6-80.el7.centos
/usr/sbin/useradd
/usr/sbin/groupadd
systemd-units
systemd-units
systemd-units
/bin/sh
/bin/sh
/bin/sh
/bin/sh
/bin/sh
/bin/sh
第二种:repoquery -R 包名
[root@xuegod140 Packages]# repoquery -R httpd
/bin/sh
/etc/mime.types
/usr/sbin/groupadd
/usr/sbin/useradd
httpd-tools = 2.4.6-80.el7.centos
libapr-1.so.0()(64bit)
(7)查询软件包是否被修改
[root@xuegod140 ~]# rpm -V zsh
[root@xuegod140 ~]# echo aaa >which zsh
#echo aaa > /usr/bin/zsh
[root@xuegod140 ~]# rpm -V zsh
S.5…T. /bin/zsh
[root@xuegod140 Packages]# rpm -Vf /usr/bin/zsh
S.5…T. /bin/zsh
[root@xuegod140 ~]# rpm -Va > check.txt #查询所有软件包是否被修改,并输出到check.txt中
(8)卸载安装的软件包
[root@xuegod140 Packages]# rpm -qa zsh #查询是否安装zsh包
zsh-5.0.2-28.el7.x86_64
[root@xuegod140 Packages]# rpm -e zsh #卸载zsh包
[root@xuegod140 Packages]# rpm -qa zsh #再次查询是否安装
[root@xuegod140 Packages]# #没有任何输出说明已经卸载成功
(9)rpm包的升级
我们一般不使用rpm包进行升级,一般使用yum进行升级,可以避免rpm依赖性的要求
[root@xuegod140 Packages]# rpm -Uvh zsh-5.0.2-28.el7.x86_64.rpm
warning: zsh-5.0.2-28.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing… ################################# [100%]
Updating / installing…
1:zsh-5.0.2-28.el7 ################################# [100%]
(10)解决rpm包依赖性的问题
这里用httpd安装包进行说明,使用rpm包安装httpd包,会报错,提示需要安装依赖包,需要现将依赖包安装完毕后,在安装httpd主程序包,才能完成httpd包的安装
[root@xuegod140 Packages]# rpm -ivh httpd-2.4.6-80.el7.centos.x86_64.rpm
warning: httpd-2.4.6-80.el7.centos.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
error: Failed dependencies:
httpd-tools = 2.4.6-80.el7.centos is needed by httpd-2.4.6-80.el7.centos.x86_64
[root@xuegod140 Packages]# rpm -ivh httpd-tools-2.4.6-80.el7.centos.x86_64.rpm
warning: httpd-tools-2.4.6-80.el7.centos.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing… ################################# [100%]
Updating / installing…
1:httpd-tools-2.4.6-80.el7.centos ################################# [100%]
[root@xuegod140 Packages]# rpm -ivh httpd-2.4.6-80.el7.centos.x86_64.rpm
warning: httpd-2.4.6-80.el7.centos.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing… ################################# [100%]
Updating / installing…
1:httpd-2.4.6-80.el7.centos ################################# [100%]
yum命令在安装rpm包时可以自动处理依赖性关系,并且一次性安装所有依赖的软件包。
yum命令安装的前提需要配置yum仓库
yum仓库分为两种:一种是本地yum仓库;一种是网络yum源
yum本地仓库的配置方法,请参考,如下链接内的配置方法:
https://blog.csdn.net/baidu_39459954/article/details/80619307
这里简单说明下如何进行挂载:
有光驱的情况下,临时挂载,输入如下命令:
[root@xuegod140 ~]# mount /dev/cdrom /mnt
没有光驱的情况下,现将系统镜像上传到服务器,然后进行挂载,命令如下:
[root@xuegod140 ~]# mount -o loop /opt/*.iso /mnt #镜像在/opt/目录下
永久挂载生效,需要将命令卸载到/etc/fstab配置文件下,命令如下:
[root@xuegod140 ~]# echo “/dev/cdrpm /mnt iso9660 defaults 0 0” >> /etc/fstab #光盘模式下
[root@xuegod140 ~]# echo “/opt/*.iso /mnt iso9660 defaults,loop,ro 0 0” >> /etc/fstab
1、yum配置文件说明
yum配置文件路径:/etc/yum.conf
配置文件说明:
[root@xuegod140 Packages]# cat /etc/yum.conf
[main]
cachedir=/var/cache/yum/ b a s e a r c h / basearch/ basearch/releasever #网络下载的rpm包存放路径
keepcache=0 #是否保存下载的rpm包。0表示不保存,1表示保存
#下载的包,一般在/var/cache/yum/x86_64/,使用哪个源就到哪个源目录进行提取(base等其它)
logfile=/var/log/yum.log #yum日志文件
obsoletes=1 #更新软件包
gpgcheck=1 #是否进行校验
2、配置网络yum源
直接从阿里云下载网络yum源文件,使用wget命令进行下载
[root@xuegod140 ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
–2019-03-30 15:48:32-- http://mirrors.aliyun.com/repo/Centos-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)… 119.96.206.232, 116.211.153.234, 116.211.153.236, …
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|119.96.206.232|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 2523 (2.5K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’
100%[=============================================>] 2,523 --.-K/s in 0s
2019-03-30 15:48:32 (232 MB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo’ saved [2523/2523]
[root@xuegod140 ~]# ls /etc/yum.repos.d/
back CentOS7.repo CentOS-Base.repo epel.repo epel-testing.repo
3、yum命令详解
参数:
查询软件包的依赖性另外一个命令如下:
例子:
(1)安装zsh软件包
[root@xuegod140 ~]# yum -y install zsh
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
*base: mirrors.aliyun.com
*epel: mirrors.tuna.tsinghua.edu.cn
*extras: mirrors.aliyun.com
*updates: mirrors.aliyun.com
Resolving Dependencies
–> Running transaction check
—> Package zsh.x86_64 0:5.0.2-31.el7 will be installed
–> Finished Dependency Resolution
Dependencies Resolved
ackage Arch Version Repository Size
Installing:
zsh x86_64 5.0.2-31.el7 base 2.4 M
… #省略号代替中间生成的文件
Installed:
zsh.x86_64 0:5.0.2-31.el7
Complete!
(2)卸载zsh软件包
[root@xuegod140 ~]# yum -y remove zsh
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
–> Running transaction check
—> Package zsh.x86_64 0:5.0.2-28.el7 will be erased
–> Finished Dependency Resolution
Installed size: 5.6 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
… #省略中间的命令
Running transaction
Erasing : zsh-5.0.2-28.el7.x86_64 1/1
Verifying : zsh-5.0.2-28.el7.x86_64 1/1
Removed:
zsh.x86_64 0:5.0.2-28.el7
Complete!
** (3)更新zsh软件包**
[root@xuegod140 ~]# yum -y update zsh # 需要提前准备好升级包
[root@xuegod140 ~]# yum -y update #后面不加包名,是升级所有包
(4)查询zsh软件包
[root@xuegod140 ~]# yum search zsh
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
================================== N/S matched: zsh ===================================
zsh.x86_64 : Powerful interactive shell
zsh-lovers.noarch : A collection of tips, tricks and examples for the Z shell
Name and summary matches only, use “search all” for everything.
(5)查询zsh的相关信息
[root@xuegod140 ~]# yum info zsh
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Installed Packages
Name : zsh
Arch : x86_64
Version : 5.0.2
Release : 28.el7
Size : 5.6 M
Repo : installed
From repo : CentOS7
Summary : Powerful interactive shell
URL : http://zsh.sourceforge.net/
License : MIT
Description : The zsh shell is a command interpreter usable as an interactive login
: shell and as a shell script command processor. Zsh resembles the ksh
: shell (the Korn shell), but includes many enhancements. Zsh supports
: command line editing, built-in spelling correction, programmable
: command completion, shell functions (with autoloading), a history
: mechanism, and more.
(6)查询ls命令是那个软件包安装的
[root@xuegod140 ~]# yum provides /usr/bin/ls
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
coreutils-8.22-21.el7.x86_64 : A set of basic GNU tools commonly used in shell scripts
Repo : CentOS7
Matched from:
Filename : /usr/bin/ls
coreutils-8.22-21.el7.x86_64 : A set of basic GNU tools commonly used in shell scripts
Repo : @anaconda
Matched from:
Filename : /usr/bin/ls
(7)yum历史命令的使用
[root@xuegod140 ~]# yum history
Loaded plugins: fastestmirror, langpacks
ID | Login user | Date and time | Action(s) | Altered
11 | root | 2019-03-30 16:03 | Install | 1
10 | root | 2019-03-30 16:02 | Erase | 1
9 | root | 2019-03-30 16:01 | Install | 1
8 | root | 2019-03-30 16:01 | Erase | 1
7 | root | 2019-03-30 15:54 | Install | 1
6 | root | 2019-03-30 15:54 | Erase | 1 <
5 | root | 2019-03-29 12:13 | Install | 1 ><
4 | root | 2019-03-28 22:12 | Erase | 1 >
3 | root | 2019-03-28 22:11 | Erase | 1
2 | root | 2019-03-16 20:24 | Install | 3
1 | System | 2019-03-15 22:24 | Install | 1354
history list
[root@xuegod140 ~]# yum history undo 9 #执行回滚操作,相当于重新安装一次zsh
Loaded plugins: fastestmirror, langpacks
Undoing transaction 9, from Sat Mar 30 16:01:56 2019
Install zsh-5.0.2-28.el7.x86_64 @CentOS7
Resolving Dependencies
–> Running transaction check
—> Package zsh.x86_64 0:5.0.2-28.el7 will be erased
–> Finished Dependency Resolution
Installed size: 5.6 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Erasing : zsh-5.0.2-28.el7.x86_64 1/1
Verifying : zsh-5.0.2-28.el7.x86_64 1/1
Removed:
zsh.x86_64 0:5.0.2-28.el7
Complete!
(8)组命令的安装
[root@xuegod140 ~]# LANG=zh_CN.UTF-8
[root@xuegod140 ~]# yum group list
已加载插件:fastestmirror, langpacks
没有安装组信息文件
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
可用的环境分组:
最小安装
基础设施服务器
计算节点
文件及打印服务器
基本网页服务器
虚拟化主机
带 GUI 的服务器
GNOME 桌面
KDE Plasma Workspaces
开发及生成工作站
可用组:
传统 UNIX 兼容性
兼容性程序库
图形管理工具
安全性工具
开发工具
控制台互联网工具
智能卡支持
科学记数法支持
系统管理
系统管理工具
完成
[root@xuegod140 ~]# yum -y groupinstall “开发工具”
已加载插件:fastestmirror, langpacks
没有安装组信息文件
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
正在解决依赖关系
–> 正在检查事务
—> 软件包 gcc.x86_64.0.4.8.5-28.el7 将被 安装
—> 软件包 gcc-c++.x86_64.0.4.8.5-28.el7 将被 安装
—> 软件包 gcc-gfortran.x86_64.0.4.8.5-28.el7 将被 安装
–> 正在处理依赖关系 libquadmath-devel = 4.8.5-28.el7,它被软件包 gcc-gfortran-4.8.5-28.el7.x86_64 需要
—> 软件包 libtool.x86_64.0.2.4.2-22.el7_3 将被 安装
—> 软件包 systemtap.x86_64.0.3.2-4.el7 将被 安装
–> 正在处理依赖关系 systemtap-devel = 3.2-4.el7,它被软件包 systemtap-3.2-4.el7.x86_64 需要
–> 正在检查事务
—> 软件包 libquadmath-devel.x86_64.0.4.8.5-28.el7 将被 安装
—> 软件包 systemtap-devel.x86_64.0.3.2-4.el7 将被 安装
–> 解决依赖关系完成
依赖关系解决
正在安装 : gcc-4.8.5-28.el7.x86_64 1/7
正在安装 : libquadmath-devel-4.8.5-28.el7.x86_64 2/7
正在安装 : systemtap-devel-3.2-4.el7.x86_64 3/7
正在安装 : systemtap-3.2-4.el7.x86_64 4/7
正在安装 : gcc-gfortran-4.8.5-28.el7.x86_64 5/7
正在安装 : gcc-c+±4.8.5-28.el7.x86_64 6/7
正在安装 : libtool-2.4.2-22.el7_3.x86_64 7/7
验证中 : gcc-gfortran-4.8.5-28.el7.x86_64 1/7
验证中 : libquadmath-devel-4.8.5-28.el7.x86_64 2/7
验证中 : gcc-4.8.5-28.el7.x86_64 3/7
验证中 : systemtap-3.2-4.el7.x86_64 4/7
验证中 : gcc-c+±4.8.5-28.el7.x86_64 5/7
验证中 : systemtap-devel-3.2-4.el7.x86_64 6/7
验证中 : libtool-2.4.2-22.el7_3.x86_64 7/7
已安装:
gcc.x86_64 0:4.8.5-28.el7 gcc-c++.x86_64 0:4.8.5-28.el7
gcc-gfortran.x86_64 0:4.8.5-28.el7 libtool.x86_64 0:2.4.2-22.el7_3
systemtap.x86_64 0:3.2-4.el7
作为依赖被安装:
libquadmath-devel.x86_64 0:4.8.5-28.el7 systemtap-devel.x86_64 0:3.2-4.el7
完毕!
安装nginx源码包
1、安装源码包前,需要先安装nginx所需的依赖包
gcc;gcc++;zlib-devell;pcre;pcre-devel;openssl-devel
[root@xuegod140 ~]# yum -y install gcc gcc++ zlib-devel pcre-devel pcre openssl-devel
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
软件包 gcc-4.8.5-28.el7.x86_64 已安装并且是最新版本
没有可用软件包 gcc++。
软件包 pcre-8.32-17.el7.x86_64 已安装并且是最新版本
正在解决依赖关系
–> 正在检查事务
—> 软件包 openssl-devel.x86_64.1.1.0.2k-12.el7 将被 安装
–> 正在处理依赖关系 krb5-devel(x86-64),它被软件包 1:openssl-devel-1.0.2k-12.el7.x86_64 需要
—> 软件包 pcre-devel.x86_64.0.8.32-17.el7 将被 安装
—> 软件包 zlib-devel.x86_64.0.1.2.7-17.el7 将被 安装
–> 正在检查事务
—> 软件包 krb5-devel.x86_64.0.1.15.1-18.el7 将被 安装
–> 正在处理依赖关系 libkadm5(x86-64) = 1.15.1-18.el7,它被软件包 krb5-devel-1.15.1-18.el7.x86_64 需要
–> 正在处理依赖关系 libverto-devel,它被软件包 krb5-devel-1.15.1-18.el7.x86_64 需要
–> 正在处理依赖关系 libselinux-devel,它被软件包 krb5-devel-1.15.1-18.el7.x86_64 需要
–> 正在处理依赖关系 libcom_err-devel,它被软件包 krb5-devel-1.15.1-18.el7.x86_64 需要
–> 正在处理依赖关系 keyutils-libs-devel,它被软件包 krb5-devel-1.15.1-18.el7.x86_64 需要
–> 正在检查事务
—> 软件包 keyutils-libs-devel.x86_64.0.1.5.8-3.el7 将被 安装
—> 软件包 libcom_err-devel.x86_64.0.1.42.9-11.el7 将被 安装
—> 软件包 libkadm5.x86_64.0.1.15.1-18.el7 将被 安装
—> 软件包 libselinux-devel.x86_64.0.2.5-12.el7 将被 安装
–> 正在处理依赖关系 libsepol-devel(x86-64) >= 2.5-6,它被软件包 libselinux-devel-2.5-12.el7.x86_64 需要
–> 正在处理依赖关系 pkgconfig(libsepol),它被软件包 libselinux-devel-2.5-12.el7.x86_64 需要
—> 软件包 libverto-devel.x86_64.0.0.2.5-4.el7 将被 安装
–> 正在检查事务
—> 软件包 libsepol-devel.x86_64.0.2.5-8.1.el7 将被 安装
–> 解决依赖关系完成
正在安装:
openssl-devel x86_64 1:1.0.2k-12.el7 CentOS7 1.5 M
pcre-devel x86_64 8.32-17.el7 CentOS7 480 k
zlib-devel x86_64 1.2.7-17.el7 CentOS7 50 k
为依赖而安装:
keyutils-libs-devel x86_64 1.5.8-3.el7 CentOS7 37 k
krb5-devel x86_64 1.15.1-18.el7 CentOS7 269 k
libcom_err-devel x86_64 1.42.9-11.el7 CentOS7 31 k
libkadm5 x86_64 1.15.1-18.el7 CentOS7 175 k
libselinux-devel x86_64 2.5-12.el7 CentOS7 186 k
libsepol-devel x86_64 2.5-8.1.el7 CentOS7 77 k
libverto-devel x86_64 0.2.5-4.el7 CentOS7 12 k
总计 17 MB/s | 2.8 MB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : libcom_err-devel-1.42.9-11.el7.x86_64 1/10
正在安装 : libsepol-devel-2.5-8.1.el7.x86_64 2/10
正在安装 : pcre-devel-8.32-17.el7.x86_64 3/10
正在安装 : libselinux-devel-2.5-12.el7.x86_64 4/10
正在安装 : keyutils-libs-devel-1.5.8-3.el7.x86_64 5/10
正在安装 : libverto-devel-0.2.5-4.el7.x86_64 6/10
正在安装 : libkadm5-1.15.1-18.el7.x86_64 7/10
正在安装 : krb5-devel-1.15.1-18.el7.x86_64 8/10
正在安装 : zlib-devel-1.2.7-17.el7.x86_64 9/10
正在安装 : 1:openssl-devel-1.0.2k-12.el7.x86_64 10/10
验证中 : zlib-devel-1.2.7-17.el7.x86_64 1/10
验证中 : libkadm5-1.15.1-18.el7.x86_64 2/10
验证中 : 1:openssl-devel-1.0.2k-12.el7.x86_64 3/10
验证中 : libverto-devel-0.2.5-4.el7.x86_64 4/10
验证中 : libselinux-devel-2.5-12.el7.x86_64 5/10
验证中 : keyutils-libs-devel-1.5.8-3.el7.x86_64 6/10
验证中 : pcre-devel-8.32-17.el7.x86_64 7/10
验证中 : libsepol-devel-2.5-8.1.el7.x86_64 8/10
验证中 : libcom_err-devel-1.42.9-11.el7.x86_64 9/10
验证中 : krb5-devel-1.15.1-18.el7.x86_64 10/10
已安装:
openssl-devel.x86_64 1:1.0.2k-12.el7 pcre-devel.x86_64 0:8.32-17.el7
zlib-devel.x86_64 0:1.2.7-17.el7
作为依赖被安装:
keyutils-libs-devel.x86_64 0:1.5.8-3.el7 krb5-devel.x86_64 0:1.15.1-18.el7
libcom_err-devel.x86_64 0:1.42.9-11.el7 libkadm5.x86_64 0:1.15.1-18.el7
libselinux-devel.x86_64 0:2.5-12.el7 libsepol-devel.x86_64 0:2.5-8.1.el7
libverto-devel.x86_64 0:0.2.5-4.el7
完毕!
2、将src.rpm上传到服务器,后解压缩
[root@xuegod140 ~]# ll nginx-1.12.2.tar.gz
-rw-r–r-- 1 root root 981687 1月 30 21:46 nginx-1.12.2.tar.gz
[root@xuegod140 ~]# tar zxvf nginx-1.12.2.tar.gz
[root@xuegod140 ~]# ls
] Documents Music Pictures Videos
anaconda-ks.cfg Downloads nginx-1.12.2 Public
Desktop initial-setup-ks.cfg nginx-1.12.2.tar.gz Templates
3、创建nginx使用的用户
[root@xuegod140 nginx-1.12.2]# useradd -s /sbin/nologin nginx
[root@xuegod140 nginx-1.12.2]# cat /etc/passwd |grep nginx
nginx❌1002:1002::/home/nginx:/sbin/nologin
4、进行编译安装
1、-- prefix 后面可以指定nginx的安装路径
2、–user 后面可以指定nginx的用户
3、–group 后面可以是定nginx的组
编译完成后,执行echo $?输出是0就说明安装没有问题
[root@xuegod140 nginx-1.12.2]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx
checking for OS
+Linux 3.10.0-862.el7.x86_64 x86_64
checking for C compiler … found
+using GNU C compiler
+gcc version: 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC)
checking for gcc -pipe switch … found
checking for -Wl,-E switch … found
checking for gcc builtin atomic operations … found
Configuration summary
+using system PCRE library
+OpenSSL library is not used
+using system zlib library
nginx path prefix: “/usr/local/nginx”
nginx binary file: “/usr/local/nginx/sbin/nginx”
nginx modules path: “/usr/local/nginx/modules”
nginx configuration prefix: “/usr/local/nginx/conf”
nginx configuration file: “/usr/local/nginx/conf/nginx.conf”
nginx pid file: “/usr/local/nginx/logs/nginx.pid”
nginx error log file: “/usr/local/nginx/logs/error.log”
nginx http access log file: “/usr/local/nginx/logs/access.log”
nginx http client request body temporary files: “client_body_temp”
nginx http proxy temporary files: “proxy_temp”
nginx http fastcgi temporary files: “fastcgi_temp”
nginx http uwsgi temporary files: “uwsgi_temp”
nginx http scgi temporary files: “scgi_temp”
[root@xuegod140 nginx-1.12.2]# echo $?
0
5、按照makefile文件编译
[root@xuegod140 nginx-1.12.2]# make -j 4
[root@xuegod140 nginx-1.12.2]# echo $?
0
[root@xuegod140 nginx-1.12.2]# make install
6、启动nginx服务
[root@xuegod140 nginx-1.12.2]# cd /usr/local/nginx/
[root@xuegod140 nginx]# ls
conf html logs sbin
[root@xuegod140 nginx]# cd sbin/
[root@xuegod140 sbin]# ls
nginx
[root@xuegod140 sbin]# ./nginx
7、使用web浏览器进行访问
8、修改网页文件,可以修改显示
nginx目录下的文件代表意思:
[root@xuegod140 nginx]# ls
conf html logs sbin
conf:配置文件
html:网页文件
logs:日志文件
sbin:二进制文件
[root@xuegod140 sbin]# echo aaa >…/html/index.html #/usr/local/nginx/html/index.html
8、删除nginx文件
命令删除:make uninstall
命令有时无法删除干净,如果在安装的过程中,指定了安装路径,可以直接删除指定路径下的所有文件
[root@xuegod140 ~]# rm -rf /usr/local/nginx/
[root@xuegod140 ~]# ls /usr/local/
bin etc games include lib lib64 libexec sbin share src
上传src.rpm包到/root目录下
1、因为安装的是lrzsz命令,所以需要先卸载lrzsz命令
[root@xuegod140 ~]# ll lrzsz-0.12.20-27.1.el6.src.rpm
-rw-r–r-- 1 root root 290240 1月 30 21:46 lrzsz-0.12.20-27.1.el6.src.rpm
[root@xuegod140 ~]# yum -y remove lrzsz
已加载插件:fastestmirror, langpacks
正在解决依赖关系
–> 正在检查事务
—> 软件包 lrzsz.x86_64.0.0.12.20-36.el7 将被 删除
–> 解决依赖关系完成
依赖关系解决
正在删除:
lrzsz x86_64 0.12.20-36.el7 @anaconda 181 k
移除 1 软件包
安装大小:181 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在删除 : lrzsz-0.12.20-36.el7.x86_64 1/1
验证中 : lrzsz-0.12.20-36.el7.x86_64 1/1
删除:
lrzsz.x86_64 0:0.12.20-36.el7
完毕!
2、使用rpmbuild明编译src.rpm包
[root@xuegod140 ~]# rpmbuild --rebuild lrzsz-0.12.20-27.1.el6.src.rpm
执行上述命令后,会在root的家目录下生成一个/root/rpmbuild目录
进入目录/root/rmpbuild/RPMS/x86_64/目录下找到lrzsz的安装包,进行安装
3、进入目录,进行安装
[root@xuegod140 ~]# ls
] Downloads Pictures Videos
anaconda-ks.cfg initial-setup-ks.cfg Public
Desktop lrzsz-0.12.20-27.1.el6.src.rpm rpmbuild
Documents Music Templates
[root@xuegod140 ~]# cd rpmbuild/
[root@xuegod140 rpmbuild]# ls
BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
[root@xuegod140 rpmbuild]# cd RPMS/x86_64/
[root@xuegod140 x86_64]# ls
lrzsz-0.12.20-27.1.el7.centos.x86_64.rpm
lrzsz-debuginfo-0.12.20-27.1.el7.centos.x86_64.rpm
[root@xuegod140 x86_64]# rpm -ivh lrzsz-0.12.20-27.1.el7.centos.x86_64.rpm
准备中… ################################# [100%]
正在升级/安装…
1:lrzsz-0.12.20-27.1.el7.centos ################################# [100%]