nginx編譯和配置

來源:互聯網
上載者:User
1安裝nginx前準備工作

Yum install –y gcc gcc-c++

Yum install zlib zlib-devel

Yum install openssl

2.編譯和安裝pcre
執行如下命令:

#cd/data/software/pcre-8.32

#./configure –prefix

#make

#make install

2.編譯和安裝nginx
執行如下命令:
# cd /data/software/nginx-1.7.0
# ./configure --prefix=/data/nginx/ --with-http_ssl_module --with-http_spdy_module \
--with-http_stub_status_module --with-pcre

#Make

#Make install


–with-http_stub_status_module:支援nginx狀態查詢
–with-http_ssl_module:支援https
–with-http_spdy_module:支援google的spdy,想瞭解請百度spdy,這個必須有ssl的支援
–with-pcre:為了支援rewrite重寫功能,必須制定pcre

安裝完成啟動nginx。

[root@localhost conf]#/data/nginx/sbin/nginx (啟動nginx提示如下錯誤)

/data/nginx/sbin/nginx: error while loadingshared libraries: libpcre.so.1: cannot open shared object file: No such file ordirectory

建立軟串連

[hadoop@SCLABHADOOP01 ~]$ ln -s/usr/local/lib/libpcre.so.1 /lib64/

判斷Nginx配置是否正確命令如下:

/usr/nginx/sbin/nginx –t

/data/nginx/sbin/nginx(啟動服務)

/data/nginx/sbin/nginx-s stop(停止服務)

/data/nginx/sbin/nginx-s reload(重啟服務)

配置nginx

#server {
#偵聽80連接埠
listen 80;
#定義使用www.xx.com訪問
server_name www.xx.com;

#設定本虛擬機器主機的訪問日誌
access_log logs/www.xx.com.access.log main;

#預設請求
location / {
root /root; #定義伺服器的預設網站根目錄位置
index index.phpindex.html index.htm; #定義首頁索引檔案的名稱

server {

listen 80;

server_name bo.artronekp.net;

location/ {

root /data/software/beian/;

index index.html help.html;

}

}

以上就介紹了nginx編譯和配置,包括了方面的內容,希望對PHP教程有興趣的朋友有所協助。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.