nginx安裝詳解,nginx詳解

來源:互聯網
上載者:User

nginx安裝詳解,nginx詳解
一、環境:

1、Linux:centos6.4(32位)

2、Gcc的編譯環境。使用make命令編輯。

yum install gcc-c++

3、PCRE

PCRE(Perl Compatible Regular Expressions)是一個Perl庫,包括 perl 相容的Regex庫。nginx的http模組使用pcre來解析Regex,所以需要在linux上安裝pcre庫。

yum install -y pcre pcre-devel

註:pcre-devel是使用pcre開發的一個二次開發庫。nginx也需要此庫。

4、zlib

zlib庫提供了很多種壓縮和解壓縮的方式,nginx使用zlib對http包的內容進行gzip,所以需要在linux上安裝zlib庫。

yum install -y zlib zlib-devel

5、openssl

OpenSSL 是一個強大的安全通訊端層密碼庫,囊括主要的密碼演算法、常用的密鑰和認證封裝管理功能及SSL協議,並提供豐富的應用程式供測試或其它目的使用。

nginx不僅支援http協議,還支援https(即在ssl協議上傳輸http),所以需要在linux安裝openssl庫。

yum install -y openssl openssl-devel

二、 安裝步驟

第一步:把Nginx的安裝包上傳到linux系統。

第二步:解壓壓縮包。

[root@bogon ~]# tar -zxf nginx-1.8.0.tar.gz

第三步:進入源碼目錄。

參數設定如下:

./configure \

--prefix=/usr/local/nginx \

--pid-path=/var/run/nginx/nginx.pid \

--lock-path=/var/lock/nginx.lock \

--error-log-path=/var/log/nginx/error.log \

--http-log-path=/var/log/nginx/access.log \

--with-http_gzip_static_module \

--http-client-body-temp-path=/var/temp/nginx/client \

--http-proxy-temp-path=/var/temp/nginx/proxy \

--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \

--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \

--http-scgi-temp-path=/var/temp/nginx/scgi

第四步:make

第五步:make install

注意:上邊將臨時檔案目錄指定為/var/temp/nginx,需要在/var下建立temp及nginx目錄

三、 Nginx的啟動和停止

在nginx的安裝目錄(/usr/local/nginx/sbin)下有一個nginx的可執行檔。

啟動:[root@bogon sbin]# ./nginx 

 

訪問測試:http://192.168.25.133

 

關閉服務:

[root@bogon sbin]# ./nginx -s stop

重新載入設定檔:

[root@bogon sbin]# ./nginx -s reload

關閉防火牆:[root@bogon sbin]# service iptables stop

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.