Linux 安裝Nginx具體圖解教程


系統:Centos6.6  64

Nginx:  http://nginx.org/en/download.html 眼下最新版本號1.9.4 我下載1.8.0

下載模塊依賴性Nginx須要依賴以下3個包
1.gzip 模塊須要 zlib 庫 ( 下載: http://www.zlib.net/ )
2.rewrite 模塊須要 pcre 庫 ( 下載: http://www.pcre.org/ )
3.ssl 功能須要 openssl 庫 ( 下載: http://www.openssl.org/ )

依賴包安裝順序依次為:openssl、zlib、pcre, 然后安裝Nginx包

假設沒有安裝c++編譯環境,還得安裝,通過yum install gcc-c++完畢安裝
下載完畢后:



下一步。編譯安裝

openssl 

 

[root@localhost] tar zxvf openssl-fips-2.0.9.tar.gz

[root@localhost] cd openssl-fips-2.0.9

[root@localhost] ./config && make && make install

 

pcre:

 

[root@localhost] tar zxvf pcre-8.36.tar.gz

[root@localhost] cd pcre-8.36

[root@localhost]  ./configure && make && make install

 

zlib:

[root@localhost]tar zxvf zlib-1.2.8.tar.gz

[root@localhost] cd zlib-1.2.8

[root@localhost]  ./configure && make && make install

 

最后安裝nginx

[root@localhost]tar zxvf nginx-1.8.0.tar.gz

[root@localhost] cd nginx-1.8.0

[root@localhost]  ./configure && make && make install


安裝完畢后。可啟動nginx

啟動命令:/usr/local/nginx/sbin/nginx
發現報錯了:
error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
經網上查詢,這是linux的通病

[root@localhost nginx]# sbin/nginx
sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
[root@localhost nginx]# error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
[root@localhost nginx]# whereis libpcre.so.1
libpcre.so: /lib64/libpcre.so.0 /usr/local/lib/libpcre.so /usr/local/lib/libpcre.so.1
[root@localhost nginx]# ln -s /usr/local/lib/libpcre.so.1 /lib64
[root@localhost nginx]# sbin/nginx   
                           
先找到libpcre.so.1所在位置,然后做個軟鏈接就能夠了。
查看是否已啟動:


通過瀏覽器訪問:


看到這個就說明nginx安裝並啟動成功。

 

ps:

啟動:/usr/local/nginx/sbin/nginx
停止/又一次載入:/usr/local/nginx/sbin/nginx -s stop(quit、reload)
驗證配置文件是否合法:/usr/local/nginx/sbin/nginx -t
命令幫助:/usr/local/nginx/sbin/nginx -h


免責聲明!

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



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