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教程有興趣的朋友有所協助。