標籤:資料庫 linux 伺服器 架構 centos
到http://nginx.org/en/download.html下載最新版本的Nginx並安裝.
一 下載並安裝pcre庫ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
tar zxvf pcre-8.30.tar.gz ./configure make make install二 安裝openssl yum -y install openssl openssl-devel三 下載tcp_proxy_module到 https://github.com/yaoweibin/nginx_tcp_proxy_module 下載四 安裝nginxexport NGINX_VERSION=1.2.1curl -O http://nginx.org/downlad/nginx-$NGINX_VERSION.tar.gztar -xvzf nginx-$NGINX_VERSION.tar.gz
cd nginx-$NGINX_VERSION
patch -p1 < ../nginx_tcp_proxy_module/tcp.patch
./configure --add-module=../nginx_tcp_proxy_module/
sudo make && make install
啟動nginx上時,服務無法啟動,出現libpcre.so.1 not found的錯誤,解決方案如下:
先執行下述命令,查看
---#ldd $(which /usr/sbin/nginx)
顯示如下:
linux-vdso.so.1 => (0x00007fff7e9db000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fe4629d0000)
libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007fe462799000)
libpcre.so.1 => not found//果然沒找到
libz.so.1 => /lib64/libz.so.1 (0x00007fe462582000)
libc.so.6 => /lib64/libc.so.6 (0x00007fe4621e1000)
/lib64/ld-linux-x86-64.so.2 (0x00007fe462bfa000)
libfreebl3.so => /lib64/libfreebl3.so (0x00007fe461f7e000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fe461d7a000)
執行如下:
----#cd /lib64
----#ln -s libpcre.so.0.0.1 libpcre.so.1
再次查看一下:
----#ldd $(which /usr/sbin/nginx)
顯示已經ok了:
linux-vdso.so.1 => (0x00007fff4d7ff000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fb06f13e000)
libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007fb06ef07000)
libpcre.so.1 => /lib64/libpcre.so.1 (0x00007fb06ecda000)
libz.so.1 => /lib64/libz.so.1 (0x00007fb06eac4000)
libc.so.6 => /lib64/libc.so.6 (0x00007fb06e723000)
/lib64/ld-linux-x86-64.so.2 (0x00007fb06f368000)
libfreebl3.so => /lib64/libfreebl3.so (0x00007fb06e4c0000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fb06e2bc000)
為websocket應用實現負載平衡 http://cnodejs.org/topic/4f16442ccae1f4aa270010b3
Reverse Proxy Web Sockets with Nginx and Socket.IOhttp://www.letseehere.com/reverse-proxy-web-sockets
安裝可能出現的問題
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 --without-http_autoindex_module --without-http_geo_module --without-http_map_module --without-http_browser_module --with-http_stub_status_module --with-http_realip_module --with-pcre=../pcre-8.31
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