Linux源碼安裝Nginx0.8.54


 安裝環境:CentOS 6.2 

 

一. 准備環境
1.安裝gcc
yum install gcc gcc-c++

2.安裝pcre
為了確保能在 Nginx 中使用正則表達式進行更靈活的配置,安裝之前需要確定系統是否安裝有 PCRE(Perl Compatible Regular Expressions)包。
下載pcre-8.20.tar.gz,地址是:http://sourceforge.net/projects/pcre/files/pcre/ ,上傳至/usr/local,安裝目錄:/usr/local/pcre
# mkdir -p pcre
# tar zxvf pcre-8.20.tar.gz
# cd pcre-8.20
# ./configure --prefix=/usr/local/pcre
# make
# make install

二. 安裝Nginx
下載nginx-0.8.54.tar.gz,地址是:http://nginx.org/en/download.html ,上傳至/usr/local,安裝目錄:/usr/local
2.1.安裝
# tar zxvf nginx-0.8.54.tar.gz
#mv nginx-0.8.54 nginx
# cd nginx-0.8.54
# ./configure --sbin-path=/usr/local/nginx --conf-path=/usr/local/nginx --pid-path=/usr/local/nginx --with-http_ssl_module --with-pcre=/usr/local/pcre-8.20
# make
# make install

2.2.檢查nginx是否安裝成功
#cd /usr/local/nginx/sbin
#./nginx -t
結果顯示:
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

2.3.啟動nginx
#cd /usr/local/nginx/sbin
#./nginx


2.4.檢查是否啟動成功
客戶端ie 瀏覽器中輸入 http://ip(Linux)

其中參數:
--with-pcre=/usr/local/pcre-8.20 指的是pcre-8.20 的源碼路徑,並不是安裝路徑。

安裝成功后 /usr/local/webserver/nginx 目錄下有四個子目錄分別是:conf、html、logs、sbin 。其中 Nginx 的配置文件存放於 conf/nginx.conf,Nginx 只有一個程序文件位於 sbin 目錄下的 nginx 文件。確保系統的 80 端口沒被其他程序占用,運行 sbin/nginx 命令來啟動 Nginx,打開瀏覽器訪問此機器的 IP(地址欄輸入:127.0.0.1),如果瀏覽器出現 Welcome to nginx! 則表示 Nginx 已經安裝並運行成功。


三. 安裝過程中出現的問題
1.pcre :/configure: error: no acceptable C compiler found in $PATH See `config.log' for more details
原因是沒裝gcc
解決辦法:yum install gcc

2../configure :checking for C++ compiler default output file name... configure: error: C++ compiler cannot create executables
See `config.log' for more details.
原因是由於c++編譯器的相關package沒有安裝
解決辦法:yum install gcc-c++

3.pcre:make時報錯:[pcrecpp.lo] Error 1
原因是由於c++編譯器的相關package沒有安裝
解決辦法:yum install gcc-c++,重新configure,make && make install通過。

4../configure: error: the HTTP rewrite module requires the PCRE library
原因是需要PCRE library
解決辦法:yum -y install pcre-devel

5../configure: error: the HTTP cache module requires md5 functions
from OpenSSL library. You can either disable the module by using
--without-http-cache option, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using
--with-http_ssl_module --with-openssl=<path> options.
原因是需要OpenSSL library
解決辦法:yum -y install openssl openssl-devel

6.啟動時如果報異常error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or director
解決方法(直接運行):
32位系統 [root@sever lib]# ln -s /usr/local/lib/libpcre.so.1 /lib
64位系統 [root@sever lib]# ln -s /usr/local/lib/libpcre.so.1 /lib64


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM