pcre-8.10.tar.gz
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
nginx-1.1.1.tar.gz
http://nginx.org/
2安装 pcre 让nginx支持rewrite
[root@localhost pcre-8.33]# ./configure [root@localhost pcre-8.33]# make [root@localhost pcre-8.33]# make install
默认是不会编译进Nginx的,如果你要使用该模块,则要在编译安装Nginx时指定:
[root@localhost nginx-1.6.1]# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module [root@localhost nginx-1.6.1]# make [root@localhost nginx-1.6.1]# make install
默认安装的路径是/usr/local/nginx
更多的安装配置
./configure --prefix=/usr/local/nginx
--with-openssl=/usr/include (启用ssl)
--with-pcre=/usr/include/pcre/ (启用正规表达式)
--with-http_stub_status_module (安装可以查看nginx状态的程序)
--with-http_memcached_module (启用memcache缓存)
--with-http_rewrite_module (启用支持url重写)
3 检查是否安装成功
[root@localhost ~]# cd /usr/local/nginx/sbin [root@localhost sbin]# ./nginx -t
错误提示:
./nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
解决方案:
[root@localhost sbin]# whereis libpcre.so.1 libpcre.so: /lib/libpcre.so.0 /usr/local/lib/libpcre.so.1 /usr/local/lib/libpcre.so [root@localhost sbin]# ldd /usr/local/nginx/sbin/nginx linux-gate.so.1 => (0x00e10000) libpthread.so.0 => /lib/libpthread.so.0 (0x00bbd000) libcrypt.so.1 => /lib/libcrypt.so.1 (0x04133000) libpcre.so.1 => not found libcrypto.so.6 => /lib/libcrypto.so.6 (0x00206000) libz.so.1 => /usr/lib/libz.so.1 (0x00bd6000) libc.so.6 => /lib/libc.so.6 (0x00a49000) /lib/ld-linux.so.2 (0x00a26000) libdl.so.2 => /lib/libdl.so.2 (0x00bb7000) [root@localhost sbin]# ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1成功提示:
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
4启动nginx
cd /usr/local/nginx/sbin 目录下面 输入 ./nginx 启动 nginx
5检查是否启动成功
ie 浏览器中输入 http://192.168.15.132
6重启
/usr/local/nginx/sbin/nginx -s reload
6关闭nginxkillall -s HUP nginx
7配置nginx_status模块监控nginx
location /nginx_status { stub_status on; access_log off; allow 192.168.31.1; deny all; }
8nginx tomcat集群配置
vi /usr/local/nginx/conf/nginx.conf upstream mysrv { #weigth参数表示权值,权值越高被分配到的几率越大 #ip_hash; server 127.0.0.1:11080 weight=1; server 127.0.0.1:11081 weight=1; server 127.0.0.1:11082 weight=1; } location / { root html; index index.html index.htm; proxy_pass http://mysrv/; }