Chinaunix首页 | 论坛 | 博客
  • 博客访问: 393087
  • 博文数量: 89
  • 博客积分: 3176
  • 博客等级: 中校
  • 技术积分: 1205
  • 用 户 组: 普通用户
  • 注册时间: 2007-08-15 10:08
文章分类

全部博文(89)

文章存档

2011年(17)

2010年(19)

2009年(35)

2008年(18)

分类: 系统运维

2008-12-22 09:38:34


#################
#
#  apache
#
################

# apt-get update
# apt-get install apache2-mpm-worker
# a2enmod proxy
# a2enmod proxy_http
# a2enmod proxy_ajp
# a2enmod proxy_connect
# a2enmod rewrite
# a2enmod expires
# a2enmod deflate
 
添加ServerName到apache2.conf
# vim /etc/apache2/apache2.conf
 
ServerName 127.0.0.1
 
# /etc/init.d/apache2 restart
 
# apache2 -M
 deflate_module (shared)
 expires_module (shared)
 proxy_module (shared)
 proxy_ajp_module (shared)
 proxy_http_module (shared)
 rewrite_module (shared)
 setenvif_module (shared)
 status_module (shared)
 jk_module (shared)
 
############################
# 在debian5_lenny里,报错。
############################
debian:~# apache2 -M
apache2: bad user name ${APACHE_RUN_USER}
设置环境变量
echo 'export APACHE_RUN_USER=www-data' >>/etc/profile
echo 'export APACHE_RUN_GROUP=www-data' >>/etc/profile
echo 'export APACHE_PID_FILE=/var/run/apache2.pid' >>/etc/profile
# source /etc/profile
即可解决。
 
 
 
 
#################
#
#   jdk
#
#################
 
# cd ~
 
# wget
 
# chmod 755 jdk-6u10-linux-i586.bin
 
# ./jdk-6u11-linux-i586.bin
mv jdk1.6.0_11 /usr/local/jdk16
 
echo 'export JAVA_HOME=/usr/local/jdk16' >>/etc/profile
echo 'export PATH=$JAVA_HOME/bin:$PATH' >>/etc/profile
echo 'export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar' >>/etc/profile
echo 'export CATALINA_HOME=/usr/share/tomcat5.5' >>/etc/profile
 
# source /etc/profile
 
# env
 
# java -version
java version "1.6.0_11"
Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing)
 
 

#################
#
#   tomcat
#
#################

# apt-get install tomcat5.5
 
# apt-get install tomcat5.5-webapps

 

##########################
#
#   proxy_http 连接
#
##########################
 
编辑apache2的首页配置文件
# vim /etc/apache2/sites-available/default
后面添加
ProxyPass /
ProxyPassReverse /
 
编辑proxy.conf
# vim /etc/apache2/mods-available/proxy.conf

        #turning ProxyRequests on and allowing proxying from all may allow
        #spammers to use your proxy to send email.
        ProxyRequests Off
       
                AddDefaultCharset off
                Order deny,allow
                Allow from all                 # 编辑此处, 允许所以proxy
                #Allow from .example.com
                # Define the character set for proxied FTP directory listings
                ProxyFtpDirCharset UTF-8
       
        # Enable/disable the handling of HTTP/1.1 "Via:" headers.
        # ("Full" adds the server version; "Block" removes all outgoing Via: headers)
        # Set to one of: Off | On | Full | Block
        ProxyVia On
# /etc/init.d/apache2 reload
 
 
 
##########################
#
#   proxy_ajp 连接
#
##########################

编辑apache2的首页配置文件
# vim /etc/apache2/sites-available/default
后面添加
ProxyPass / ajp://127.0.0.1:8009
ProxyPassReverse / ajp://127.0.0.1:8009
 
确保/etc/apache2/mods-available/proxy.conf允许proxy
# /etc/init.d/apache2 reload
 
 
 
##########################
#
#   mod_jk 连接
#
##########################
 
# apt-get install libapache2-mod-jk
 
# /etc/init.d/apache2 force-reload
 
# vim /etc/apache2/conf.d/mod_jk.conf
----------------------------------------------------------------------------------------------
# 指出mod_jk模块工作所需要的工作文件workers.properties的位置
JkWorkersFile /etc/apache2/workers.properties
# Where to put jk logs
JkLogFile /var/log/apache2/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
# Where to put jkshm logs
JkShmFile /var/log/apache2/jk-runtime-status
# JkOptions indicate to send SSL KEY SIZE,
JkOptions  +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"
# 将所有servlet 和jsp请求通过ajp13的协议送给Tomcat,让Tomcat来处理
JkMount /servlet/*  worker1
JkMount /*.jsp worker1
----------------------------------------------------------------------------------------------

# vim /etc/apache2/mods-available/jk.load
LoadModule jk_module modules/mod_jk.so
Include /etc/apache2/conf.d/mod_jk.conf
 
# vim /etc/apache2/workers.properties
---------------------------------------------------------------
# Defining a worker named worker1 and of type ajp13
worker.list=worker1
# Set properties for worker1
worker.worker1.type=ajp13 
worker.worker1.host=localhost 
worker.worker1.port=8009
worker.worker1.lbfactor=50 
worker.worker1.cachesize=10 
worker.worker1.cache_timeout=600 
worker.worker1.socket_keepalive=1 
worker.worker1.socket_timeout=300
---------------------------------------------------------------
 

##################################################### 参考 ################################################
 
 
##########################
#
#   tomcat无法开机启动
#
##########################
# 原因是JAVA的环境改变,与默认配置不符,需修改开机启动文件/etc/rc2.d/S90tomcat5.5
# vim /etc/rc2.d/S90tomcat5.5
  1.PATH路径修改 -- /usr/local/jdk16/bin
  2.JDK_DIRS路径修改 --/usr/local/jdk16
# 修改点如下:
--------------------------------------------------------------
---23 PATH=/usr/local/jdk16/bin:/bin:/usr/bin:/sbin:/usr/sbin
---40 JDK_DIRS="/usr/local/jdk16 /usr/lib/jvm/java-1.5.0-sun /usr/lib/j2sdk1.4-sun /usr/lib/j2sdk1.4-blackdown /usr/lib/j2se/1.4/ usr/lib/j2sdk1.5-sun /usr/lib/j2sdk1.3-sun /usr/lib/j2sdk1.3-blackdown /usr/lib/j2sdk1.5-ibm /usr/lib/j2sdk1.4-ibm /usr/lib/ jvm/java-gcj /usr/lib/kaffe"
--------------------------------------------------------------
 
 
JSP测试文件
---------------------------------------------------------------
< contentType="text/html"%>
< pageEncoding="UTF-8"%>
"">



JSP Test Page


   

JSP Test Page


   
    <%= new java.util.Date() %>


------------------------------------------------------------------
 
 
tomcat默认虚拟目录
--------------------------------------------------------------------------------------------------
     
     
            unpackWARs="true" autoDeploy="true"
      xmlValidation="false" xmlNamespaceAware="false">
     
     
---------------------------------------------------------------------------------------------------- 
 
 
 
 
 
阅读(2088) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2010-09-08 23:55:11

root@debian:~# /etc/init.d/apache2 restart Restarting web server: apache2We failed to correctly shutdown apache, so we're now killing all running apache processes. This is almost certainly suboptimal, so please make sure your system is working as you'd expect now! (warning). ... waiting Syntax error on line 2 of /etc/apache2/conf.d/mod_jk.conf: JkWorkersFile only allowed once 按您的配置完毕后我重启apache 提示这个错误 我qq30431151 希望得到您的帮助 liyun@socom.cn