Linux 下 Nginx 整合 tomcat

Nginx 详细介绍请参看 [url=http://baike.baidu.com/view/926025.htm] 百度百科链接[/url]
[url=http://nginx.org/en/download.html]nginx主页[/url]下载最新版

[url=http://nginx.org/download/nginx-1.0.4.tar.gz]nginx-1.0.4.tar.gz [/url]
最新的!!

到/usr/local/
tar  zxvf  nginx-1.0.4.tar.gz   
cd nginx-1.0.4
./configure --with-http_stub_status_module --with-http_ssl_module



此时如果如下错误
./configure: error: the HTTP cache module requires md5 functions   
from OpenSSL library. You can either disable the module by using
--without-http-cache option, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using
--with-http_ssl_module --with-openssl=<path> options.


使用
yum -y install pcre-devel openssl openssl-devel   


如果无错误提示

make    
make install


安装完成后会在/usr/local/nginx目录下

cd /usr/local/nginx/sbin/

./nginx –t  #(检查nginx.conf文件)如出现如下文字代表配置文件无问题
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

./nginx     启动服务器

访问地址(端口默认为80)出现以下文字

Welcome to nginx


./nginx  -s stop  停止服务器



整合 TOMCAT

cd /usr/local/nginx/conf/
vi proxy.conf


加入如下配置:
proxy_redirect          off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; #获取真实IP
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #获取代理者的真实ip
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;


保存

cd /usr/local/nginx/conf/
vi nginx.conf


http {
include mime.types;
default_type application/octet-stream;
include /usr/local/nginx/conf/proxy.conf; #引入以上proxy.conf文件
#--------------------------------------#
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
#---------------------------------------#
以上为可选配置,可不写或选填


    server {
listen 80;
server_name admin.zch.com;
index index.html index.htm;
root /usr/local/apache-tomcat-6.0.32/webapps/admin/;
#为资源路径,就是说你该项目的静态页面与图片等其他东西存放

location ~ .*.(jsp|action)$ #所有.jsp.action的页面均交由tomcat处理
{
index index.jsp;
proxy_pass http:// admin.zch.com:8080;#转向tomcat处理
}


此处省略TOMCAT相关域名配置

配置保存过后

cd /usr/local/nginx/sbin/
./nginx -s stop
./nginx


然后按照域名访问!OK!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值