Linux 程序包管理

一、基于RPM管理程序包

RPM:Redhat Package Manager,即RPM软件包管理器,是Linux系统中的一种包管理工具,用于对软件包的安装、升级、卸载、查询、检验等操作。

1、rpm安装程序包的基本用法

语法格式:

  rpm {-i|--install} [install-options] PACKAGE_FILE ...
  rpm -ivh [install-options] PACKAGE_FILE ...

安装选项:

  --replacepkgs :重新安装一个程序包        
  --nodeps :在安装程序包时忽略依赖关系
  --test :测试安装,而不执行真正的安装


来几个实际操作:

安装软件包epel-release-6-8.noarch.rpm:

[root@localhost ~]# rpm -ivh epel-release-6-8.noarch.rpm 
warning: epel-release-6-8.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing...                ########################################### [100%]
   1:epel-release           ########################################### [100%]
[root@localhost ~]#

再次安装:

[root@localhost ~]# rpm -ivh epel-release-6-8.noarch.rpm 
warning: epel-release-6-8.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing...                ########################################### [100%]
	package epel-release-6-8.noarch is already installed
[root@localhost ~]#

此时就会提示已安装过了。。


使用--replacepkgs选项重新安装:

[root@localhost ~]# rpm -ivh --replacepkgs epel-release-6-8.noarch.rpm 
warning: epel-release-6-8.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing...                ########################################### [100%]
   1:epel-release           ########################################### [100%]
[root@localhost ~]#


忽略程序包之间的依赖关系:

[root@localhost ~]# rpm -ivh bind-9.8.2-0.30.rc1.el6.x86_64.rpm 
error: Failed dependencies:
	bind-libs = 32:9.8.2-0.30.rc1.el6 is needed by bind-32:9.8.2-0.30.rc1.el6.x86_64
	libbind9.so.80()(64bit) is needed by bind-32:9.8.2-0.30.rc1.el6.x86_64
	libdns.so.81()(64bit) is needed by bind-32:9.8.2-0.30.rc1.el6.x86_64
	libisc.so.83()(64bit) is needed by bind-32:9.8.2-0.30.rc1.el6.x86_64
	libisccc.so.80()(64bit) is needed by bind-32:9.8.2-0.30.rc1.el6.x86_64
	libisccfg.so.82()(64bit) is needed by bind-32:9.8.2-0.30.rc1.el6.x86_64
	liblwres.so.80()(64bit) is needed by bind-32:9.8.2-0.30.rc1.el6.x86_64
[root@localhost ~]#

加上--nodeps选项:

[root@localhost ~]# rpm -ivh --nodeps bind-9.8.2-0.30.rc1.el6.x86_64.rpm 
Preparing...                ########################################### [100%]
   1:bind                   ########################################### [100%]
[root@localhost ~]#

此时可以发现,程序已成功被装上了,但建议不要使用这种方式安装程序包。。


2、rpm升级程序包的基本用法

语法格式:

  rpm {-U|--upgrade} [install-options] PACKAGE_FILE ...
  rpm {-F|--freshen} [install-options] PACKAGE_FILE ...

-U和-F的区别:-U选项是在升级程序包时,如果有较旧的此程序包,则升级安装;如果此程序包未安装的,则执行新安装操作;而-F选项仅仅执行升级安装,而不会全新安装;

升级软件包的常用选项:

  --oldpackages:降级安装
  --force:忽略冲突强制执行安装


3、rpm卸载程序包

语法格式:

  rpm -e PACKAGE_NAME ...

常用选项:

  --force:忽略依赖关系,强制卸载

如果没有依赖关系,则可以直接卸载:

[root@localhost ~]# rpm -e tcsh
[root@localhost ~]#

瞬间被御-_-

如果有依赖关系的,还可以使用--force选项执行强制卸载。


4、rpm程序包查询

语法格式:

  rpm -q [options]

查询软件包是否已安装,后面接的程序包名称;

查询某个包是否已安装:

[root@localhost ~]# rpm -q zip
zip-3.0-1.el6.x86_64
[root@localhost ~]#


查询所有已安装的程序包:

rpm -qa


查询一个文件是由哪个包生成的:

[root@localhost ~]# rpm -qf /bin/bash
bash-4.1.2-29.el6.x86_64
[root@localhost ~]#


查看某个程序包所有文件列表:

[root@localhost ~]# rpm -qlp tcsh-6.17-24.el6.x86_64.rpm 
/bin/csh
/bin/tcsh
/usr/share/doc/tcsh-6.17
/usr/share/doc/tcsh-6.17/BUGS
/usr/share/doc/tcsh-6.17/FAQ
/usr/share/doc/tcsh-6.17/Fixes
/usr/share/doc/tcsh-6.17/NewThings
/usr/share/doc/tcsh-6.17/README
/usr/share/doc/tcsh-6.17/WishList
/usr/share/doc/tcsh-6.17/complete.tcsh
/usr/share/locale/de/LC_MESSAGES/tcsh
/usr/share/locale/el/LC_MESSAGES/tcsh
/usr/share/locale/en/LC_MESSAGES/tcsh
/usr/share/locale/es/LC_MESSAGES/tcsh
/usr/share/locale/et/LC_MESSAGES/tcsh
/usr/share/locale/fi/LC_MESSAGES/tcsh
/usr/share/locale/fr/LC_MESSAGES/tcsh
/usr/share/locale/it/LC_MESSAGES/tcsh
/usr/share/locale/ja/LC_MESSAGES/tcsh
/usr/share/locale/pl/LC_MESSAGES/tcsh
/usr/share/locale/ru/LC_MESSAGES/tcsh
/usr/share/locale/uk/LC_MESSAGES/tcsh
/usr/share/man/man1/csh.1.gz
/usr/share/man/man1/tcsh.1.gz
[root@localhost ~]#


查询尚未安装包的简要信息:

[root@localhost ~]# rpm -qip tcsh-6.17-24.el6.x86_64.rpm 
Name        : tcsh                         Relocations: (not relocatable)
Version     : 6.17                              Vendor: CentOS
Release     : 24.el6                        Build Date: Fri 22 Feb 2013 12:19:26 PM CST
Install Date: (not installed)               Build Host: c6b9.bsys.dev.centos.org
Group       : System Environment/Shells     Source RPM: tcsh-6.17-24.el6.src.rpm
Size        : 1196177                          License: BSD
Signature   : RSA/SHA1, Sun 24 Feb 2013 01:40:34 AM CST, Key ID 0946fca2c105b9de
Packager    : CentOS BuildSystem <http://bugs.centos.org>
URL         : http://www.tcsh.org/
Summary     : An enhanced version of csh, the C shell
Description :
Tcsh is an enhanced but completely compatible version of csh, the C
shell.  Tcsh is a command language interpreter which can be used both
as an interactive login shell and as a shell script command processor.
Tcsh includes a command line editor, programmable word completion,
spelling correction, a history mechanism, job control and a C language
like syntax.
[root@localhost ~]#


查询已安装程序包生成的所有文件:

[root@localhost ~]# rpm -ql bash
/bin/bash
/bin/sh
/etc/skel/.bash_logout
/etc/skel/.bash_profile
/etc/skel/.bashrc
/usr/bin/bashbug-64
/usr/share/doc/bash-4.1.2/COPYING
/usr/share/info/bash.info.gz
/usr/share/locale/af/LC_MESSAGES/bash.mo
/usr/share/locale/bg/LC_MESSAGES/bash.mo
/usr/share/locale/ca/LC_MESSAGES/bash.mo
/usr/share/locale/cs/LC_MESSAGES/bash.mo
/usr/share/locale/de/LC_MESSAGES/bash.mo
/usr/share/locale/en@boldquot/LC_MESSAGES/bash.mo
...略...


查询已安装包的简要信息:

[root@localhost ~]# rpm -qi bash
Name        : bash                         Relocations: (not relocatable)
Version     : 4.1.2                             Vendor: CentOS
Release     : 29.el6                        Build Date: Thu 16 Oct 2014 09:58:35 PM CST
Install Date: Tue 25 Nov 2014 04:34:50 PM CST      Build Host: c6b8.bsys.dev.centos.org
Group       : System Environment/Shells     Source RPM: bash-4.1.2-29.el6.src.rpm
Size        : 3140846                          License: GPLv3+
Signature   : RSA/SHA1, Sat 18 Oct 2014 04:03:01 AM CST, Key ID 0946fca2c105b9de
Packager    : CentOS BuildSystem <http://bugs.centos.org>
URL         : http://www.gnu.org/software/bash
Summary     : The GNU Bourne Again shell
Description :
The GNU Bourne Again shell (Bash) is a shell or command language
interpreter that is compatible with the Bourne shell (sh). Bash
incorporates useful features from the Korn shell (ksh) and the C shell
(csh). Most sh scripts can be run by bash without modification.
[root@localhost ~]#


查询安装包生成的配置文件列表:

[root@localhost ~]# rpm -qc bash
/etc/skel/.bash_logout
/etc/skel/.bash_profile
/etc/skel/.bashrc
[root@localhost ~]#


查询已安装程序包的帮助文件列表:

[root@localhost ~]# rpm -qd bash
/usr/share/doc/bash-4.1.2/COPYING
/usr/share/info/bash.info.gz
/usr/share/man/man1/..1.gz
/usr/share/man/man1/:.1.gz
/usr/share/man/man1/[.1.gz
/usr/share/man/man1/alias.1.gz
/usr/share/man/man1/bash.1.gz
/usr/share/man/man1/bashbug.1.gz
/usr/share/man/man1/bg.1.gz
/usr/share/man/man1/bind.1.gz
/usr/share/man/man1/break.1.gz
/usr/share/man/man1/builtin.1.gz
/usr/share/man/man1/builtins.1.gz
/usr/share/man/man1/caller.1.gz
/usr/share/man/man1/cd.1.gz
...略...


查询程序包的改变日志:

[root@localhost ~]# rpm -q --changelog bash
* Fri Sep 26 2014 Michal Hlavinka <[email protected]> - 4.1.2-29
- CVE-2014-7169
  Resolves: #1146323

* Mon Sep 15 2014 Ondrej Oprala <[email protected]> - 4.1.2-28
- Fix-up the patch
  Related: #1141646

* Mon Sep 15 2014 Ondrej Oprala <[email protected]> - 4.1.2-27
- Check for fishy environment
  Related: #1141646
  ...略...
* Mon Oct 20 1997 Erik Troan <[email protected]>
- added comment explaining why install-info isn't used
- added mips patch

* Fri Oct 17 1997 Donnie Barnes <[email protected]>
- added BuildRoot

* Tue Jun 03 1997 Erik Troan <[email protected]>
- built against glibc
[root@localhost ~]#


5、检查包的来源合法性及完整性

语法格式:

rpm --import PUBKEY ...


没导入公钥之前:

[root@repo ~]# rpm -K tcsh-6.17-24.el6.x86_64.rpm
tcsh-6.17-24.el6.x86_64.rpm: RSA sha1 ((MD5) PGP) md5 NOT OK (MISSING KEYS: (MD5) PGP#c105b9de) 
[root@repo ~]#

导入公钥并再次验证:

[root@localhost ~]# rpm --import RPM-GPG-KEY-CentOS-6 
[root@localhost ~]# rpm -K tcsh-6.17-24.el6.x86_64.rpm 
tcsh-6.17-24.el6.x86_64.rpm: rsa sha1 (md5) pgp md5 OK
[root@localhost ~]#


不检查包的来源合源性:

[root@localhost ~]# rpm -K --nosignature tcsh-6.17-24.el6.x86_64.rpm 
tcsh-6.17-24.el6.x86_64.rpm: sha1 md5 OK
[root@localhost ~]#
一般检查程序包的来源是否合法,只需验证签名是否一致。


不检查包的完整性:

[root@localhost ~]# rpm -K --nodigest tcsh-6.17-24.el6.x86_64.rpm 
tcsh-6.17-24.el6.x86_64.rpm: rsa (md5) pgp OK
[root@localhost ~]# 
一般检查程序包的完整性,只验验证md5是否一致。


二、基于YUM管理程序包

yum是基于rpm的一个前端管理工具,但它比rpm更加易用;yum包管理器是通过从指定的软件仓库中自动下载RPM包并且安装,还可以自动解决软件包之间的依赖关系关自动完成安装;

1、yum常用选项和命令

选项:

  --enablerepo=REPO_NAME :临时打开某个软件仓库
  --disablerepo=REPO_NAME :临时关闭某个软件仓库
  --nogpgcheck :安装软件包时不检查签名
  -y :安装软件包时自动回答为yes

安装:

  yum install package1 [package2] [...] :安装软件包
  yum restall package1 [package2] [...] :重新安装

升级:

  yum update [package1] [package2] [...]:升级单个或多个软件
  yum update:更新系统上已安装的软件包

卸载:

  yum remove package1 [package2] [...]:卸载软件包

查询:

  yum list:列出所有软件包
  yum info PACKAGE_NAME:查询某个软件包的信息
  yum search KEYWORD:根据关键字搜索软件包
  yum provides FILE_NAME:根据文件查询是由哪个软件包提供的

包组:

  yum grouplist:查询所有包组
  yum groupinfo GROUP_NAME:查询某个包组的相关信息
  yum groupinstall GROUP_NAME:安装包组
  yum groupremove GROUP_NAME:卸载包组
  yum groupupdate GROUP_NAME:升级包组:

其它:

  yum还可安装本地rpm包文件:
  yum localinstall RPM_PACKAGE_FILE


2、修改配置文件,使用互联网上的软件仓库

备份原有的配置文件:

mv /etc/yum.repos.d/{CentOS-Base.repo,CentOS-Base.repo.backup}

从互联网下载对应repo文件,并放入/etc/repos.d/目录下,然后运行以下命令生成缓存:

yum clean all
yum makecache


3、制作本地的软件仓库

创建一个本地目录:

[root@localhost ~]# mkdir -v /tmp/repo
mkdir: created directory `/tmp/repo'
[root@localhost ~]#

挂载镜像盘至/mnt目录:

[root@localhost ~]# mount -r /dev/sr0 /mnt/

复制/mnt/Packages目录下所有文件至/tmp/repo目录:

[root@localhost ~]# cp -a /mnt/Packages/* /tmp/repo/

生成仓库元数据信息:

[root@localhost ~]# createrepo /tmp/repo/
Spawning worker 0 with 215 pkgs
Workers Finished
Gathering worker results

Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@localhost ~]#

添加repo配置文件:

[root@localhost ~]# cat > /etc/yum.repos.d/local.repo
[local]
name=local repo
baseurl=file:///tmp/repo/
enabled=1
gpgcheck=0
[root@localhost ~]#

查看本地仓库是否生效:

[root@localhost ~]# yum repolist 
Loaded plugins: downloadonly, fastestmirror
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
local                                                                | 2.9 kB     00:00 ... 
local/primary_db                                                     | 477 kB     00:00 ... 
repo id           repo name                                                           status
base              CentOS 6 x86_64 on local server 172.16.0.1                           4,184
epel              Fedora EPEL for CentOS6 x86_64 on local server 172.16.0.1           12,922
extra             CentOS 6 x86_64 extras                                               2,334
local             local repo                                                             215
repolist: 19,655
[root@localhost ~]#
由上面的结果可以看出,本地仓库已成功创建


三、基于源码包编译安装程序包

源码安装一般需要的几个步骤:

1.获取源码包,从软件官方或其它路径获取

2.准备编译环境,安装基本的编译工具

3.解压源码包,执行configure检查编译环境,并根据指定的选项确定编译的特性、安装路径等

4.执行make程序进行编译

5.执行make install安装程序

6.新增程序库的找路径配置文件,一般存放在/etc/ld.so.conf.d/目录中(这一步一般都不需要,看具体情况)

7.添加二进制程序所在路径至PATh环境变量中,用于实现在命令行中直接查找程序并运行

以编译nginx为例:


下载源码包:

[root@localhost ~]# wget http://nginx.org/download/nginx-1.6.0.tar.gz
--2015-02-10 22:04:10--  http://nginx.org/download/nginx-1.6.0.tar.gz
Resolving nginx.org... 206.251.255.63
Connecting to nginx.org|206.251.255.63|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 802956 (784K) [application/octet-stream]
Saving to: “nginx-1.6.0.tar.gz”

100%[==================================================>] 802,956     4.54K/s   in 88s     

2015-02-10 22:05:39 (8.93 KB/s) - “nginx-1.6.0.tar.gz” saved [802956/802956]

[root@localhost ~]#


安装gcc编译工具:

[root@localhost ~]# yum install gcc -y
Loaded plugins: downloadonly, fastestmirror
Setting up Install Process
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.4.7-11.el6 will be installed
--> Processing Dependency: libgomp = 4.4.7-11.el6 for package: gcc-4.4.7-11.el6.x86_64
--> Processing Dependency: cpp = 4.4.7-11.el6 for package: gcc-4.4.7-11.el6.x86_64
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc-4.4.7-11.el6.x86_64
...略...
Installed:
  gcc.x86_64 0:4.4.7-11.el6                                                              
Dependency Installed:
  cloog-ppl.x86_64 0:0.15.7-1.2.el6             cpp.x86_64 0:4.4.7-11.el6                
  glibc-devel.x86_64 0:2.12-1.149.el6           glibc-headers.x86_64 0:2.12-1.149.el6    
  kernel-headers.x86_64 0:2.6.32-504.el6        libgomp.x86_64 0:4.4.7-11.el6            
  mpfr.x86_64 0:2.4.1-6.el6                     ppl.x86_64 0:0.10.2-11.el6               
Complete!
[root@localhost ~]#


解压源码包,并运行configure程序:

[root@localhost ~]# tar xf nginx-1.6.0.tar.gz 
[root@localhost ~]# cd nginx-1.6.0
[root@localhost nginx-1.6.0]# ./configure --prefix=/usr/local/nginx
checking for OS
 + Linux 2.6.32-504.el6.x86_64 x86_64
checking for C compiler ... found
 + using GNU C compiler
 + gcc version: 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC) 
checking for gcc -pipe switch ... found
checking for gcc builtin atomic operations ... found
checking for C99 variadic macros ... found
checking for gcc variadic macros ... found
checking for unistd.h ... found
checking for inttypes.h ... found
checking for limits.h ... found
checking for sys/filio.h ... not found
...略...
checking for PCRE library in /usr/include/pcre/ ... not found
checking for PCRE library in /usr/pkg/ ... not found
checking for PCRE library in /opt/local/ ... not found

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

[root@localhost nginx-1.6.0]#

出现一个错误,不过,根据提示可以知道是缺少一个PCRE库导致的,安装pcre库即可:

[root@localhost nginx-1.6.0]# yum install pcre-devel -y
Loaded plugins: downloadonly, fastestmirror
Setting up Install Process
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package pcre-devel.x86_64 0:7.8-6.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================
 Package                 Arch                Version                Repository         Size
============================================================================================
Installing:
 pcre-devel              x86_64              7.8-6.el6              base              318 k

Transaction Summary
============================================================================================
Install       1 Package(s)

Total download size: 318 k
Installed size: 954 k
Downloading Packages:
pcre-devel-7.8-6.el6.x86_64.rpm                                      | 318 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : pcre-devel-7.8-6.el6.x86_64                                              1/1 
  Verifying  : pcre-devel-7.8-6.el6.x86_64                                              1/1 

Installed:
  pcre-devel.x86_64 0:7.8-6.el6                                                             

Complete!
[root@localhost nginx-1.6.0]#

重启执行configure程序,成功后会出现以下信息:

Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + using builtin md5 code
  + sha1 library is not found
  + using system zlib library

 nginx path prefix: "/usr/local/nginx"
 nginx binary file: "/usr/local/nginx/sbin/nginx"
 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@localhost nginx-1.6.0]# make 
make -f objs/Makefile
make[1]: Entering directory `/root/nginx-1.6.0'
...略...
make[1]: Leaving directory `/root/nginx-1.6.0'
make -f objs/Makefile manpage
make[1]: Entering directory `/root/nginx-1.6.0'
sed -e "s|%%PREFIX%%|/usr/local/nginx|" \
		-e "s|%%PID_PATH%%|/usr/local/nginx/logs/nginx.pid|" \
		-e "s|%%CONF_PATH%%|/usr/local/nginx/conf/nginx.conf|" \
		-e "s|%%ERROR_LOG_PATH%%|/usr/local/nginx/logs/error.log|" \
		< man/nginx.8 > objs/nginx.8
make[1]: Leaving directory `/root/nginx-1.6.0'
[root@localhost nginx-1.6.0]#


安装:

[root@localhost nginx-1.6.0]# make install
make -f objs/Makefile install
make[1]: Entering directory `/root/nginx-1.6.0'
test -d '/usr/local/nginx' || mkdir -p '/usr/local/nginx'
test -d '/usr/local/nginx/sbin' 		|| mkdir -p '/usr/local/nginx/sbin'
test ! -f '/usr/local/nginx/sbin/nginx' 		|| mv '/usr/local/nginx/sbin/nginx''/usr/local/nginx/sbin/nginx.old'
cp objs/nginx '/usr/local/nginx/sbin/nginx'
test -d '/usr/local/nginx/conf' 		|| mkdir -p '/usr/local/nginx/conf'
cp conf/koi-win '/usr/local/nginx/conf'
cp conf/koi-utf '/usr/local/nginx/conf'
cp conf/win-utf '/usr/local/nginx/conf'
test -f '/usr/local/nginx/conf/mime.types' 		|| cp conf/mime.types '/usr/local/nginx/conf'
cp conf/mime.types '/usr/local/nginx/conf/mime.types.default'
test -f '/usr/local/nginx/conf/fastcgi_params' 		|| cp conf/fastcgi_params '/usr/local/nginx/conf'
cp conf/fastcgi_params 		'/usr/local/nginx/conf/fastcgi_params.default'
test -f '/usr/local/nginx/conf/fastcgi.conf' 		|| cp conf/fastcgi.conf '/usr/local/nginx/conf'
cp conf/fastcgi.conf '/usr/local/nginx/conf/fastcgi.conf.default'
test -f '/usr/local/nginx/conf/uwsgi_params' 		|| cp conf/uwsgi_params '/usr/local/nginx/conf'
cp conf/uwsgi_params 		'/usr/local/nginx/conf/uwsgi_params.default'
test -f '/usr/local/nginx/conf/scgi_params' 		|| cp conf/scgi_params '/usr/local/nginx/conf'
cp conf/scgi_params 		'/usr/local/nginx/conf/scgi_params.default'
test -f '/usr/local/nginx/conf/nginx.conf' 		|| cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf'
cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf.default'
test -d '/usr/local/nginx/logs' 		|| mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/logs' || 		mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/html' 		|| cp -R html '/usr/local/nginx'
test -d '/usr/local/nginx/logs' || 		mkdir -p '/usr/local/nginx/logs'
make[1]: Leaving directory `/root/nginx-1.6.0'
[root@localhost nginx-1.6.0]#


添加二进制程序到PATH环境变量中:

[root@localhost nginx-1.6.0]# export PATH=/usr/local/nginx/sbin/:$PATH
[root@localhost nginx-1.6.0]# echo $PATH
/usr/local/nginx/sbin/:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[root@localhost nginx-1.6.0]#


到此,编译安装完成,执行nginx即可启动程序:

[root@localhost nginx-1.6.0]# nginx
[root@localhost nginx-1.6.0]# ss -atn | grep :80
LISTEN     0      128                       *:80                       *:*     
[root@localhost nginx-1.6.0]#

编译成功^-^


至此,本文完。。





發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章