nginx for linux安裝及安裝錯誤解決


nginx:下載地址:http://www.nginx.org/

1.GCC編譯器

        安裝指令 :yum  install -y  gcc    

        如果你所使用的是ubuntu,則安裝指令為:apt-get install -y  gcc        因為ubuntu可不用yum,下同哦..............

        如果涉及到C++來編寫Nginx HTTP模塊,則還需要安裝G++編譯器

        安裝指令:yum install -y gcc-c++

2. PCRE庫

        首先我們需要下載PCRE,這個步驟簡單,我們可以自行完成。例如這里我們下載的安裝包為pcre-8.34.tar.gz,我們需要用到移動到指定的文件夾下面,然后解壓安裝。

      移動指令:mv “指定文件目錄”  “目標文件目錄”。假設我們需要將源碼移動到/home目錄下 mv  /home  "源碼所在目錄/pcre-8.34.tar.gz"

      解壓指令:tar zxvf pcre-8.34.tar.gz   然后執行如下指令。

      cd /home/pcre-8.34

      ./configure  此過程中會生成一大堆文件,不用去管它。

      make

      make install

3.OpenSSL開發庫

     yum  install -y openssl openssl-devel  

     如果是ubuntu系統,安裝指令:# sudo apt-get install openssl # sudo apt-get install libssl-dev

OK,准備工作已經做完,我們來安裝Nginx。首先得下載源碼,然后將其移動到目標文件夾,當然也可以就地解壓。這里我們以nginx-1.6.0.tar.gz,移動到/home目錄下來進行實例說明。cd到/home目錄,解壓。

      # tar zxvf nginx-1.6.0.tar.gz

      # cd nginx-1.6.0

      ./configure --prefix=/usr/local/nginx --with-http_stub_status_module

make

make install

如果在make的時候出現make: *** 沒有規則可以創建“default”需要的目標“build”這種提示,請回到OpenSSL開發庫的安裝上去,一般是這一步出了問題。而且你肯定沒有注意./configure時候的錯誤提示:

./configure: error: the HTTP cache module requires md5 functionsfrom 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= options.

如果一切都沒有問題,我們來檢查下安裝是否成功。

  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

則表示安裝正確,現在我們來啟動Nginx:

cd  /usr/local/nginx/sbin

./nginx 啟動 nginx

這個時候打開瀏覽器,輸入自己電腦的ip。對於不知道自己電腦ip的童靴,可以使用ifconfig指令進行查看。

這里我在瀏覽器中輸入:http://127.0.0.1 出現如下信息:

 

看到上面nginx 歡迎界面說明啟動成功

          停止nginx: pkill -9 nginx

參考:http://www.th7.cn/system/lin/201406/61021.shtml

出現問題:Nginx: error while loading shared libraries: libpcre.so.1

Shell代碼  
[ew69@localhost conf]# /usr/local/nginx/sbin/nginx  
/usr/local/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory  
 
確認已經安裝PCRE: 
Shell代碼  
[ew69@SCLABHADOOP01 lib]$ cd /lib  
[ew69@SCLABHADOOP01 lib]$ ls *pcre*  
libpcre.so.0  libpcre.so.0.0.1  
[hadoop@SCLABCLUS01 nginx]$ find / -type f -name *libpcre.so.*   
添加軟鏈接:
Shell代碼  
[ew69@SCLABHADOOP01 lib]$ ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1  
前面在一般的linux上可以解決此問題.
 
注: 在有的操作 系統上面,安裝pcre后,安裝的位置為/usr/local/lib/*pcre*
在redhat 64位機器之上有這樣的情況.
在redhat 64位機器上, nginx可能讀取的pcre文件為/lib64/libpcre.so.1文件.
所以在改用下面的軟連接:
Shell代碼  
[hadoop@SCLABHADOOP01 ~]$ ln -s /usr/local/lib/libpcre.so.1 /lib64/ 
 
新手初學呀!多方借鑒!


免責聲明!

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



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