當前位置:
首頁 > 最新 > Linux安裝Nginx

Linux安裝Nginx

1、安裝PCRE

下載PCRE

wget http://downloads.sourceforge.net/project/pcre/pcre/8.39/pcre-8.39.tar.gz

最新版本可以在 https://sourceforge.net/projects/pcre/files/pcre/ 看到。

解壓pcre.我是下載在 /usr/local/nginx/ 下的。

tar zxvf pcre-8.39.tar.gz #step 1cd pcre-8.39 #step 2./configure #step 3make && make install #step 4

其中在Step 3 可能出現下面兩個問題:

1、出現no acceptable C compiler found in $PATH 則需要安裝GCC組件

yum install gcc

2、出現 You need a C++ compiler for C++ support 問題 則需要再安裝 GCC-C++ 組件

yum install gcc-c++

安裝完成後,使用

pcre-config --version

可以查看版本。

2、安裝Nginx

可以在Nginx官網查看最新版本,複製以.tar.gz結尾的地址

如:http://nginx.org/download/nginx-1.11.6.tar.gz

執行

wget http://nginx.org/download/nginx-1.11.6.tar.gztar zxvf nginx-1.11.6.tar.gz cd nginx-1.11.6./configure --prefix=/etc/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/nginx/pcre-8.39

其中 --prefix 為安裝Nginx的路徑,--with-pcre 為pcre的路徑。

1、如果出現 error: SSL modules require the OpenSSL library 則需要安裝OpenSSL

可以從OpenSSL官網查看最新版本

複製鏈接

https://www.openssl.org/source/openssl-1.1.0c.tar.gz

安裝:

wget https://www.openssl.org/source/openssl-1.1.0c.tar.gz tar zxvf openssl-1.1.0c.tar.gzcd openssl-1.1.0c.tar.gz ./config -t

會提示需要安裝Perl 5

Operating system: x86_64-whatever-linux2 You need Perl 5.

Perl 5 官網查看最新版本

複製地址

http://www.cpan.org/src/5.0/perl-5.24.0.tar.gz

wget http://www.cpan.org/src/5.0/perl-5.24.0.tar.gz tar -xzf perl-5.24.0.tar.gz cd perl-5.24.0 ./Configure -des -Dprefix=$HOME/localperl make make testmake install

2、安裝Zlib

可以在這裡下載

然後安裝:

tar xvf zlib-1.2.8.tar.gzcd zlib-1.2.8 ./configure make && make install

再進入到Nginx的解壓目錄,進行 make install 安裝,這裡命令有所變化添加了OpenSSL和Zlib

./configure --prefix=/etc/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/nginx/pcre-8.39 --with-openssl=/usr/local/nginx/openssl-1.1.0c --with-zlib=/usr/local/nginx/zlib-1.2.8make && make install

現在就可以在 /etc/nginx/ 下面看到 Nginx 的安裝文件了。

單獨啟動 Nginx

./nginx -s reload

也可以將 Nginx 添加為系統服務

首先 vi /etc/init.d/nginx

輸入內容,參考這裡

chkconfig --add nginx chkconfig nginx on

修改 nginx.conf


喜歡這篇文章嗎?立刻分享出去讓更多人知道吧!

本站內容充實豐富,博大精深,小編精選每日熱門資訊,隨時更新,點擊「搶先收到最新資訊」瀏覽吧!


請您繼續閱讀更多來自 清風軒 的精彩文章:

TAG:清風軒 |