apache+jboss+jdk
1、 安装jdk
比如我们存放路径/backup/jdk-6u12-linux-i586.bin
Chmod +x jdk-6u12-linux-i586.bin
执行以下命令: ./ jdk-6u12-linux-i586.bin
解压后得到jdk1.6.0_12
Mv jdk1.6.0_12 /usr/local/jdk1.6.0_12
设置环境变量:vi /etc/profile
#---------------------------------jboss jdk start-----------------------
JAVA_HOME=/usr/local/jdk1.6.0_12
JBOSS_HOME=/usr/local/jboss
JBOSS_HOST=0.0.0.0
JBOSS_USER=root
CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib
PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin
export JBOSS_HOME JAVA_HOME JBOSS_HOST JBOSS_USER CLASSPATH PATH
#---------------------------------jboss jdk end-------------------------
2、安装jboss
Cd /backup
Unzip jboss-4.2.3.GA-jdk6.zip
Mv jboss-4.2.3.GA /usr/local/jboss
操作source /etc/profile使环境变量生效
Java -version如果出现:
java version "1.6.0_12"
Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
Java HotSpot(TM) Server VM (build 11.2-b01, mixed mode)
3、编译安装Apache
由于我们安装的是apache2.2版本,所以需要先安装arp和arp-util这两个文件
a、安装arp
#./configure --prefix=/usr/lcoal/apr
#make && make install
b、安装apr-util
#./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
#make
#make install
c、安装apache(编译时加入ajp代理以及反向代理参数以及负载均衡参数)
#./configure --prefix=/usr/local/apache --enable-proxy --enable-proxy-ajp
--enable-proxy-balancer --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
(最好要支持rewrite)
#make
#make install
4、使用mod.jk来结合apache和jboss
先下载mod.jk
根据我们需要的版本下载即可,我这里用的是64位操作系统,所以下载
mod_jk-1.2.27-httpd-2.2.6.so-64
下载后cp mod_jk-1.2.27-httpd-2.2.6.so-64 /usr/local/apache/modules/mod_jk.so
然后在httpd.conf中添加模块
a、LoadModule jk_module modules/mod_jk.so
b、打开虚拟机文件
Include conf/extra/httpd-vhosts.conf
c、创建一个配置文件workers.properties
# JKWorkersFile
JKWorkersFile conf/extra/workers.properties
d、然后在/usr/local/apache/conf/extra/中创建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
e、再配置/usr/local/apache/conf/extra/httpd-vhosts.conf,作以下修改:
增加mod_jk的配置:
ServerAdmin xxxxx
DocumentRoot "/webserver/test"
ServerName 192.168.7.251
JKMount /test/servlet/* worker1
JKMount /test/*.jsp worker1
JKMount /test/*.do worker1
RewriteEngine On
RewirteRule ^/$ /test/ [R,P]
SetEnv force-proxy-request-1.0.1
SetEnv proxy-nokeepalive 1
#rewrite 访问转到 地址栏显示
# 最后两行设置是防止IE5.5以下版本的浏览器访问出现问题
增加图片访问目录
Options FollowSymLinks
AllowOverride All
Order deny,allow
Allow from all
DirectoryIndex /default.png
ErrorDocument 404 /default.png
# 如果没有指定图片显示的默认图
DocumentRoot "/webserver/photo"
ServerAdmin
ServerName hys.com
ServerAlias hys.com
!
然后保存退出 启动apache和jboss 访问http://你的ip地址/ 打开jboss页面就可以了
对于多虚拟机的配置要在站点的根目录下自己做跳转。
比如我的测试index.html
然后做jsp的测试文件。test/test.jsp
<%@ page contentType="text/html;charset=gb2312"%>
HI-JSP实验
<%
String Msg = "This is JSP test! 看到这段话,恭喜你,成功了!";
out.print("Hello World!");
%>
<%=Msg%>
The current date and time is <%=new java.util.Date() %>
<%
String str = "Using trim() and substring() can be very useful";
out.println(str);
%>
如果从页面可以看到,说明配置成功了。
阅读(1312) | 评论(0) | 转发(0) |