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]#

編譯成功^-^


至此,本文完。。





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