Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7118331
  • 博文数量: 3857
  • 博客积分: 6409
  • 博客等级: 准将
  • 技术积分: 15948
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-02 16:48
个人简介

迷彩 潜伏 隐蔽 伪装

文章分类

全部博文(3857)

文章存档

2017年(5)

2016年(63)

2015年(927)

2014年(677)

2013年(807)

2012年(1241)

2011年(67)

2010年(7)

2009年(36)

2008年(28)

分类:

2012-05-30 20:04:00

                Nginx+tomcat
 
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devellibidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
 
 
一、安装tomcat:
1)、安装jdk:
 
[root@localhost java]# mkdir -p /usr/java
[root@localhost java]# tar zxvf jdk-7u3-linux-x64.tar.gz -C /usr/java/
[root@localhost java]# vi /etc/profile
JAVA_HOME="/usr/java/jdk1.7.0_03"
CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
Export ………JAVA_HOME CLASSPATH
[root@localhost java]# source /etc/profile
[root@localhost java]# java -version
java version "1.7.0_03"
Java(TM) SE Runtime Environment (build 1.7.0_03-b04)
Java HotSpot(TM) 64-Bit Server VM (build 22.1-b02, mixed mode)
二、安装tomcat:
 
Tomcat 下载:
 
# tar zxvf apache-tomcat-7.0.26.tar.gz -C /usr/src/
# cd /usr/src/
# cp -rf apache-tomcat-7.0.26 /usr/local/tomcat1
# cp -rf apache-tomcat-7.0.26 /usr/local/tomcat2
# cd /usr/local/tomcat1
# vi /etc/profile
将第一个TOMCAT安装在/usr/local/tomcat1
export TOMCAT_HOME=/usr/local/tomcat1
export CATALINA_HOME=/usr/local/tomcat1
export CATALINA_BASE=/usr/local/tomcat1
CLASSPATH后面添加$TOMCAT_HOME/common/lib/servlet.jar
PATH后面添加:$CATALINA_HOME/lib
 
将第二个TOMCAT安装在/usr/local/tomcat2
设置环境变量
#vi /etc/profile
export TOMCAT_2_HOME=/usr/local/tomcat2
export CATALINA_2_HOME=/usr/local/tomcat2
export CATALINA_2_BASE=/usr/local/tomcat2
CLASSPATH后面添加$TOMCAT_2_HOME/common/lib/servlet.jar
PATH后面添加:$CATALINA_2_HOME/lib
保存退出
:wq
使环境变量生效
#source /etc/profile
 
修改TOMCAT配置文件/usr/local/tomcat2/conf/server.xml
 
将以下内容
    ...
   
   
   
    .../>
修改为
    ...
   
   
   
    .../>
   
修改TOMCAT配置启动文件/usr/local/tomcat2/bin/startup.sh
 
exec上添加以下内容
export JAVA_HOME=/usr/local/java/jdk1.7.0_03
export CLASSPATH=$JAVA_HOME/lib
export PATH=$JAVA_HOME/bin:$PATH  
 %注意,网上好多写成export PATH=$JAVA_HOME/bin的,在启动时会报错误%
export CATALINA_HOME=$CATALINA_2_HOME
export CATALINA_BASE=$CATALINA_2_BASE
 
修改TOMCAT配置启动文件/usr/local/tomcat2/bin/shutdown.sh
 
exec上添加以下内容
export JAVA_HOME=/usr/local/java/jdk1.7.0_03
export CLASSPATH=$JAVA_HOME/lib
export PATH=$JAVA_HOME/bin:$PATH
export CATALINA_HOME=$CATALINA_2_HOME
export CATALINA_BASE=$CATALINA_2_BASE
 
启动TOMCAT
/usr/local/tomcat2/bin/startup.sh
关闭TOMCAT
/usr/local/tomcat2/bin/shutdown.sh
 
# vi ./conf/server.xml
 
(把 删掉 这是注释内容)
  (虚拟目录1)
   
               connectionTimeout="20000"
               redirectPort="8443" />
   
 
   
 
     
       
               resourceName="UserDatabase"/>
     
 
     
            unpackWARs="true" autoDeploy="true">
 
       
               prefix="localhost_access_log." suffix=".txt"
               pattern="%h %l %u %t "%r" %s %b" />
 
       
   
 
 
    (虚拟目录2)
 
  
              connectionTimeout="20000"
              redirectPort="8443" />
 
  
 
    
            resourceName="UserDatabase"/>
 
    
           unpackWARs="true" autoDeploy="true"
           xmlValidation="false" xmlNamespaceAware="false">
 
     
   
 
 
 
三、安装nginx:
 
nginx 下载 :
pcre :
 
1)、安装pcre:
# tar zxvf pcre-8.30.tar.gz -C /usr/src/
# cd /usr/src/pcre-8.30/
# make && make install
 
2)、安装插件upstream、
# tar zxvf nginx-1.0.13.tar.gz -C /usr/src/
# tar zxvf nginx-upstream-jvm-route-0.1.tar.gz -C /usr/src/
 
# cd /usr/src/nginx-1.0.13/
 
# patch -p0 < /usr/src/nginx_upstream_jvm_route/jvm_route.patch
3)、安装nginx:
# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-pcre=/usr/src/pcre-8.30 --add-module=/usr/src/nginx_upstream_jvm_route --with-openssl=/usr/ ( --user= --group=)
# make && make install
 
4)、编辑nginx.conf:
 
# vi /usr/local/nginx/conf/nginx.conf
 
user nobody;
worker_processes 8;
error_log logs/nginx_error.log crit;
pid        /usr/local/nginx/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 20480;
events
{
 use epoll;
 worker_connections 20480;
}
 
http {
 
 
 upstream aa {
       server 127.0.0.1:8080 max_fails=3 fail_timeout=50s;
 }
 upstream bb {
       server 127.0.0.1:8081 max_fails=3 fail_timeout=50s;
 }
 
 include       mime.types;
 default_type application/octet-stream;
 #charset gb2312;
 charset UTF-8;
 server_names_hash_bucket_size 128;
 client_header_buffer_size 32k;
 large_client_header_buffers 4 32k;
 client_header_timeout 20;
 client_max_body_size 20m;
 sendfile on;
 tcp_nopush     on;
 keepalive_timeout 60;
 tcp_nodelay on;
 proxy_connect_timeout 30;
 proxy_read_timeout 60;
 proxy_send_timeout 20;
 proxy_buffer_size 96k;
 proxy_buffers 8 256k;
 proxy_busy_buffers_size 512k;
 proxy_temp_file_write_size 512k;
# proxy_store on;
# proxy_store_access user:rw group:rw all:rw;
 proxy_temp_path /usr/local/nginx/proxy_temp;
proxy_cache_path /usr/local/nginx/www levels=1:2 keys_zone=cache_one:20m inactive=1d max_size=2g;
 gzip on;
 gzip_proxied any;
 gzip_min_length 1k;
 gzip_buffers     4 16k;
 gzip_http_version 1.0;
 gzip_comp_level 2;
 gzip_types       text/plain application/x-javascript text/css application/xml;
 gzip_vary on;
# limit_zone one $binary_remote_addr 10m;
 proxy_set_header Host $host;
 proxy_set_header X-Real-IP $remote_addr;
 proxy_set_header X-Forwarded-For $remote_addr;
 
 
 server {
        listen       80;
        server_name 192.168.3.30;
        index index.html;
#    rewrite ^/index.html     /   last;
#rewrite ^/(.*)_p([0-9]*)_(.*)_e(.*)/(.*)_(.*)_t(.*)_o(.*)_(l|s|k|[0-9]*)$   /searchclassbigkey?skey=$1&pno=$2&sw=$3&pe=$4&rk=$5&dekey=$6&tid=$7&ocs=$8&ocid=$9 last;
#rewrite ^/(.*)_p([0-9]*)_s(.*)/(.*)_(.*)_(.*)$ /searchkey?skey=$1&pno=$2&sw=$3&pe=$4&rk=$5&dekey=$6 last;
# rewrite ^/d-(.*)$       /detaillist?id=$1 last;
 
 
 location /
    {
#     proxy_next_upstream http_502 http_504 error timeout invalid_header;
#     proxy_headers_hash_max_size 1024;
#     proxy_headers_hash_bucket_size 128;
#     proxy_cache cache_one;
     proxy_cache_valid 200 304 2h;
     proxy_cache_valid any 30m;
     proxy_cache_key $host$uri$is_args$args;
#     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_pass
 }
 
 
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
#     proxy_cache cache_one;
     proxy_cache_valid 200 304 5h;
     proxy_cache_valid any 3m;
     proxy_cache_key $host$uri$is_args$args;
     expires      8h;
     proxy_pass 
   }
 
 
 location ~ .*\.(js|css|html)$
   {
#     proxy_cache cache_one;
     proxy_cache_valid 200 304 3h;
     proxy_cache_valid any 3m;
     proxy_cache_key $host$uri$is_args$args;
     expires      5h;
     proxy_pass 
}
 
 
log_format aa '$remote_addr - $remote_user [$time_local] "$request" '
             '$status $body_bytes_sent "$http_referer" '
             '"$http_user_agent" $http_x_forwarded_for';
 access_log /usr/local/nginx/logs/aa.log aa;
 
}
 
 server {
   listen       80;
   server_name 192.168.3.31;
   index index.html;
 
 
 location /
    {
     proxy_cache cache_one;
     proxy_cache_valid 200 304 2h;
     proxy_cache_valid any 3m;
     proxy_cache_key $host$uri$is_args$args;
     proxy_pass
    }
 
   location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css|html)$
    {
     proxy_cache cache_one;
     proxy_cache_valid 200 304 5h;
     proxy_cache_valid any 3m;
     expires      8h;
     proxy_cache_key $host$uri$is_args$args;
     proxy_pass 
   }
log_format bb '$remote_addr - $remote_user [$time_local] "$request" '
             '$status $body_bytes_sent "$http_referer" '
             '"$http_user_agent" $http_x_forwarded_for';
 access_log /usr/local/nginx/logs/bb.log bb;
 
}
 
}
 
# /usr/local/nginx/sbin/nginx -t
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
 
# /usr/local/nginx/sbin/nginx
# netstat -anpt | grep 80         
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      30169/nginx  
 
# /usr/local/nginx/sbin/nginx –s reload
 

本文出自 “要成长要收获” 博客,请务必保留此出处http://s2t148.blog.51cto.com/3858027/851446

阅读(618) | 评论(0) | 转发(0) |
0

上一篇:TCP/UDP端口列表

下一篇:一些iptables 规则

给主人留下些什么吧!~~