安装和使用nginx

1下载 
pcre-8.10.tar.gz
[url]ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/[/url] 
nginx-1.1.1.tar.gz
[url]http://nginx.org/[/url]
2安装 pcre 让nginx支持rewrite
[code="shell"]
# ./configure
# make
# make install
[/code]

默认是不会编译进Nginx的,如果你要使用该模块,则要在编译安装Nginx时指定:
[code="shell"]
# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module
# make
# make install
[/code]
默认安装的路径是/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 检查是否安装成功
[code="shell"]
# cd /usr/local/nginx/sbin
# ./nginx -t
[/code]

错误提示:
./nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
解决方案:
[code="shell"]
# whereis libpcre.so.1
libpcre.so: /lib/libpcre.so.0 /usr/local/lib/libpcre.so.1 /usr/local/lib/libpcre.so
# 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)
# ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1
[/code]成功提示:
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

[img]http://dl2.iteye.com/upload/attachment/0099/9767/0f2c8485-a754-3096-ac39-4a524031ca6d.jpg[/img]
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/;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值