Centos6.9安裝部署nginx服務器
(一)依賴包安裝
首先,gcc,pcre,zlib,openssl安裝一邊(可以用非-devel,但是嫌麻煩....用非-devel的看這個鏈接)
yum -y install gcc
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
(再次執行./configure
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.)-->只是為了研究過程,實際中不需要每次都./configure
yum install pcre-devel
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
再次執行./configure./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
再次執行./configureConfiguration summary
+ using system PCRE library
+ OpenSSL library is not used
+ using builtin md5 code
+ sha1 library is not found
+ using system zlib library
OK,現在可以執行make 了。 如果你想使用openssl 功能,sha1 功能。 那麽安裝openssl ,sha1 吧,騷年。 安裝openssl yum install openssl openssl-devel 安裝sha1
yum install perl-Digest-SHA1.x86_64
開啟ssl 模塊 執行./configure --with-http_ssl_module
啟用“server+status"頁,執行./configure --with-http_stub_status_module
兩個都啟動,不用我說了。執行./configure --with-http_stub_status_module --with-http_ssl_module
( -devel和非-devel的區別:
devel 包主要是供開發用,至少包括以下2個東西:
1. 頭文件
2. 鏈接庫
有的還含有開發文檔或演示代碼。
以 glib 和 glib-devel 為例:
如果你安裝基於 glib 開發的程序,只需要安裝 glib 包就行了。
但是如果你要編譯使用了 glib 的源代碼,則需要安裝 glib-devel。)
(二)Nginx安裝
常規的非-devel包用這種方法:
$ cd /usr/local/ $ wget http://nginx.org/download/nginx-1.8.0.tar.gz $ tar -zxvf nginx-1.8.0.tar.gz $ cd nginx-1.8.0 $ ./configure --prefix=/usr/local/nginx $ make $ make install
在--prefix後面接以下命令:
--with-pcre=/usr/local/pcre-8.36 指的是pcre-8.36 的源碼路徑。 --with-zlib=/usr/local/zlib-1.2.8 指的是zlib-1.2.8 的源碼路徑
不過,現在既然用了-devel包,就直接操作!很簡單直接。
------------------------------
那麽configre 就通過了。------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
執行make 命令
執行make install 命令
至此,nginx 執行成功了---------------------------------------------------------------------
啟動
$ /usr/local/nginx/sbin/nginx
用瀏覽器直接訪問ipv4,顯示Nginx默認頁面,搞定!
Centos6.9安裝部署nginx服務器