Centos 6.0/ Nginx 安装与配置
生活随笔
收集整理的這篇文章主要介紹了
Centos 6.0/ Nginx 安装与配置
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?
系統:Centos?6.0
下載nginx(nginx-1.2.4.tar.g)???http://nginx.org/ 下載pcre(pcre-8.31.tar.gz)????http://pcre.org/ 一、安裝之前首先確認系統中是否已安裝gcc、openssl-devel、pcre-devel、zlib-devel #yum?-y?install?gcc?openssl-devel?pcre-devel?zlib-devel 二、安裝pcre-devel庫(使Nginx支持http?rewrite的模塊) #tar?zxvf?pcre-8.31.tar.gz??????#cd?pcre-8.31
??????#./congigure
??????#make
??????#make?install 問題:
????libtool:?compile:?unrecognized?option?`-DHAVE_CONFIG_H'
????libtool:?compile:?Try?`libtool?--help'?for?more?information.
????make[1]:?***?[pcrecpp.lo]?Error?1
????make[1]:?Leaving?directory?`/home/guangbo/work/pcre-8.12'
????make:?***?[all]?Error?2
???缺少gcc-c++和libtool,也就是c++編譯包
???解決方法:需要先安裝libtool和gcc-c++
???#yum?-y?install?libtool
???#yum?-y?install?gcc-c++ 三、安裝Nginx
???#tar?zxvf?nginx-1.2.4.tar.gz
???#cd?nginx-1.2.4
???#./configure?--with-http_stub_status_module?--with-http_gzip_static_module
?????--?prefix=/usr/local/nginx
???#make
???#makeinstall
???????????--with-http_gzip_static_module?支持在線實時壓縮輸出數據流。 問題: 1、若在./configure后配置剛才的參數,提示一下的錯誤: objs/src/http/modules/ngx_http_browser_module.o?\
objs/src/http/modules/ngx_http_upstream_ip_hash_module.o?\
objs/src/http/modules/ngx_http_upstream_least_conn_module.o?\
objs/src/http/modules/ngx_http_upstream_keepalive_module.o?\
objs/ngx_modules.o?\
-lpthread?-lcrypt?-lpcre?-lcrypto?-lcrypto?-lz
objs/src/core/ngx_regex.o:?In?function?`ngx_pcre_free_studies':
/share/nginx-1.2.4/src/core/ngx_regex.c:307:?undefined?reference?to?`pcre_free_study'
collect2:?ld?returned?1?exit?status
make[1]:?***?[objs/nginx]?Error?1
make[1]:?Leaving?directory?`/share/nginx-1.2.4'
make:?***?[build]?Error?2 解決方法: ./configure??--prefix=/usr/local/nginx?--with-http_ssl_module?--with-http_sub_module?--with-http_stub_status_module?--add-module=../ngx_cache_purge-2.1???--with-http_gzip_static_module? PS:???./configure?--prefix=/usr/localnx?--without-http_autoindex_module?--without-http_geo_module?--with-pcre=../pcre-8.31 注意:把--with-pcre=../pcre-8.31換成你的pcre解壓縮包的路徑
2、若在“./configure”后方加入了“--with-http_gzip_static_module”(添加gzip壓縮模塊)提?示以下錯誤:
./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.
解決辦法:安裝zlib-devel包 #yum?-y?install??zlib-devel 啟動Nginx出現的問題:
#?/usr/local/nginx/sbin/nginx
1、/usr/local/nginx/sbin/nginx:?error?while?loading?shared?libraries:?libpcre.so.1:?cannot?open?shared?object?file:?No?such?file?or?directory
從錯誤看出是缺少lib文件導致,進一步查看下
#?ldd?$(which?/usr/local/nginx/sbin/nginx)
linux-gate.so.1?=>?(0x0071b000)
libpthread.so.0?=>?/lib/libpthread.so.0?(0×00498000)
libcrypt.so.1?=>?/lib/libcrypt.so.1?(0×00986000)
libpcre.so.1?=>?not?found
libcrypto.so.6?=>?/lib/libcrypto.so.6?(0×00196000)
libz.so.1?=>?/lib/libz.so.1?(0×00610000)
libc.so.6?=>?/lib/libc.so.6?(0x002d7000)
/lib/ld-linux.so.2?(0x006a8000)
libdl.so.2?=>?/lib/libdl.so.2?(0x008c3000)
可以看出?libpcre.so.1?=>?not?found?并沒有找到,進入/lib目錄中手動鏈接下
#?ln?-s?libpcre.so.0.0.1?libpcre.so.1 然后在啟動nginx?ok?了
#?/usr/local/nginx/sbin/nginx
#?ps?-aux|grep?nginx
Warning:?bad?syntax,?perhaps?a?bogus?'-'??See?/usr/share/doc/procps-3.2.7/FAQ
root?28254?0.0?0.0?2688?460???Ss?17:16?0:00?nginx:?master?process?/usr/local/nginx/sbin/nginx
nobody?28255?0.0?0.0?2860?816???S?17:16?0:00?nginx:?worker?process?
root?28265?0.0?0.0?4160?688?pts/1?R+?17:16?0:00?grep?nginx 2、Nginx啟動失敗,提示端口已被占用提示:
nginx:?[emerg]?bind()?to?0.0.0.0:80?failed?(98:?Address?already?in?use)
nginx:?[emerg]?bind()?to?0.0.0.0:80?failed?(98:?Address?already?in?use)
nginx:?[emerg]?bind()?to?0.0.0.0:80?failed?(98:?Address?already?in?use)
nginx:?[emerg]?bind()?to?0.0.0.0:80?failed?(98:?Address?already?in?use)
至此Nginx安裝完畢。
本文轉自 kuangling 51CTO博客,原文鏈接:http://blog.51cto.com/kling/1021483
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀
總結
以上是生活随笔為你收集整理的Centos 6.0/ Nginx 安装与配置的全部內容,希望文章能夠幫你解決所遇到的問題。

- 上一篇: VSS自动发布站点功能扩展
- 下一篇: keepalived之 Keepaliv