將nginx-1.8.0.tar.gz拷貝至linux服務器。linux
解壓:nginx
tar -zxvf nginx-1.8.0.tar.gzc++
cd nginx-1.8.0服務器
一、 configureui
./configure --help查詢詳細參數(參考本教程附錄部分:nginx編譯參數)spa
參數設置以下:.net
./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
2. 編譯安裝code
makeblog
make install教程
3.安裝成功後檢查
注意:上邊將臨時文件目錄指定爲/var/temp/nginx,須要在/var下建立temp及nginx目錄
遇到錯誤:
./configure: error: the HTTP rewrite module requires the PCRE library
解決:
yum -y install pcre-devel openssl openssl-devel
./configure --prefix=/usr/local/nginx
make
make install
其間可能碰到錯誤:
錯誤①:依賴軟件prce,ssl,zlib未安裝錯誤
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
須要安裝pcre包
Pcre
tar zxvf pcre-8.12.tar.gz
cd pcre-8.12
./configure
make
make install
nginx 啓動
./nginx -c /usr/local/nginx/conf/nginx.conf
在網址上輸入:192.168.152.131:80 //192.168.152.131是我虛擬機linux的ip
錯誤②:pcre3編譯報錯:libtool: compile: unrecognized option `-DHAVE_CONFIG_H'
解決方法:
該錯誤是因爲缺乏 gcc-c++ 包。
若是是debian系統,運行:
[plain] view plain copy print ?
若是是redhat系統,運行:
[plain] view plain copy print ?