gcc
安裝nginx需要先將官網下載的源碼進行編譯,編譯依賴gcc環境,如果沒有gcc環境,需要安裝gcc:
yum install gcc-c++
PCRE
PCRE(Perl Compatible Regular Expressions)是一個Perl庫,包括 perl 兼容的正則表達式庫。nginx的http模塊使用pcre來解析正則表達式,所以需要在linux上安裝pcre庫。
注:pcre-devel是使用pcre開發的一個二次開發庫。nginx也需要此庫。
yum install -y pcre pcre-devel
zlib
zlib庫提供了很多種壓縮和解壓縮的方式,nginx使用zlib對http包的內容進行gzip,所以需要在linux上安裝zlib庫。
yum install -y zlib zlib-devel
openssl
OpenSSL 是一個強大的安全套接字層密碼庫,囊括主要的密碼算法、常用的密鑰和證書封裝管理功能及SSL協議,並提供豐富的應用程序供測試或其它目的使用。
nginx不僅支持http協議,還支持https(即在ssl協議上傳輸http),所以需要在linux安裝openssl庫。
yum install -y openssl openssl-devel
下載tengine包
wget http://tengine.taobao.org/download/tengine.tar.gz
tar zvxf tengine.tar.gz
./configure --prefix=/opt/nginx (安裝到/opt/nginx 目錄下)
make && make install
cd /opt/nginx
./sbin/nginx -t (檢測配置文件)
如果顯示下面信息,即表示配置沒問題
nginx: the configuration file /opt/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /opt/nginx/conf/nginx.conf test is successful
[root@centos ~]# ./sbin/nginx
[root@centos ~]# ps au|grep nginx
如果顯以類似下面的信息,即表示nginx已經啓動
root 2013 0.0 0.0 103156 856 pts/0 S+ 03:22 0:00 grep nginx
詳情請看 :http://blog.csdn.net/qq_15766181/article/details/51959921