linux下nginx安裝

 因爲nginx的安裝需要依賴其他庫,所以要先安裝依賴庫。以下是具體步奏


http://nginx.org/download/nginx-1.2.8.tar.gz

 1.安裝PCRE庫
cd /usr/local/
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz
tar -zxvf pcre-8.36.tar.gz
cd pcre-8.36
./configure
make
make install


注意:因爲有些64位機器需要加入一下軟連接nginx才能讀取得到
ln -s /usr/local/lib/libpcre.so.1 /lib64/


2.安裝zlib庫
cd /usr/local/
wget http://zlib.net/zlib-1.2.8.tar.gz
tar -zxvf zlib-1.2.8.tar.gz 
cd zlib-1.2.8
./configure
make
make install
 
3.安裝ssl
方法一:
yum -y install openssl openssl-devel
方法二:
cd /usr/local/
wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
tar -zxvf openssl-1.0.1c.tar.gz
./config
make
make install

4.安裝nginx
cd /usr/local/
wget http://nginx.org/download/nginx-1.6.2.tar.gz
tar -zxvf nginx-1.6.2.tar.gz
cd nginx-1.6.2  
./configure --prefix=/usr/local/nginx-1.6.2 --with-http_ssl_module --with-http_gzip_static_module --with-openssl=/usr/local/ssl

make
make install
//建立一個軟連接
ln -s /usr/local/nginx-1.6.2 nginx
注意:
--with-http_ssl_module 是爲了配置https訪問所需的模塊

--with-http_gzip_static_module 是靜態壓縮模塊


啓動nginx::

/usr/local/nginx/sbin/nginx

檢查配置文件:

/usr/local/nginx/sbin/nginx -t

指定配置文件啓動:

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

重啓:

/usr/local/nginx/sbin/nginx -s reload

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