在 CentOS 6.x 安裝 Nginx Light Web Server

Nginx 是一套輕量級的 Web Server,和 Apache Web Server 比起來,由俄羅斯程式設計師 Igor Sysoev 所開發輕量級的網頁伺服器,軟體以 BSD-like 授權,可以在 UNIX、GNU/Linux、BSD、Mac OS X、Solaris,以及Microsoft Windows 等作業系統中執行。

Nginx 官方網站:http://nginx.org/

目前有人在 Linux 使用它來取代 Apache Web Server,並把這個組合稱為 LNMP(Linux + Nginx + MySQL + PHP)[@more@]安裝方式:
因為 Nginx 並不是 CentOS 官方套件,所以必須先新增 Nginx 官方所提供的第三方套件庫
# vim /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1

匯入憑證
# rpm –import http://nginx.org/keys/nginx_signing.key


# wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
# rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm

更新套件庫
# yum update

安裝 Nginx Web Server
# yum install nginx

執行 Nginx Web Server
# service nginx start
Starting nginx:                                            [  OK  ]

設定開機預設啟動 Nginx 和關閉 Apache Web Server
# chkconfig –level 3 nginx on
# chkconfig –level 3 httpd off

開啟瀏覽器,連線到 Nginx Web Server