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

來源:互聯網
上載者:User

標籤:

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代碼  [[email protected] 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代碼  [[email protected] lib]$ cd /lib  [[email protected] lib]$ ls *pcre*  libpcre.so.0  libpcre.so.0.0.1  [[email protected] nginx]$ find / -type f -name *libpcre.so.*   添加軟連結:Shell代碼  [[email protected] 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代碼  [[email protected] ~]$ ln -s /usr/local/lib/libpcre.so.1 /lib64/  新手初學呀!多方借鑒!

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

聯繫我們

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