Oracle/DB2/Postgresql/Mysql/Hadoop/Greenplum/Postgres-xl/Mongodb
分类: LINUX
2013-07-23 18:44:31
Centos4.4+Apache2.2.4+tomcat6.0.14+jdk1.5整合安装
安装步骤:
1) jdk-1_5_0_07-linux-i586.bin
#cp jdk-1_5_0_07-linux-i586.bin /usr/local/
#cd /usr/local
#chmod +x jdk-1_5_0_07-linux-i586.bin
#./ jdk-1_5_0_07-linux-i586.bin
#vi /etc/profile
加入以下几行
export JAVA_HOME=/usr/local/jdk
export CLASSPATH=$JAVA_HOME/lib
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
export CATALINA_HOME=/usr/local/tomcat
保存退出。
#source /etc/profiel
#java –version 查看jdk是否安装成功
2) httpd-2.2.4.tar.gz
#cp httpd-2.2.4.tar.gz /usr/local
#cd /usr/local
#tar zxvf httpd-2.2.4.tar.gz
#cd httpd-2.2.4
#./configure –prefix=/usr/local/apache --enable-module=so
#make
#make install
启动Apache,并测试。
# cd /usr/local/apache/bin
# ./apachectl start
打开浏览器,并在地址栏中输入主机的IP地址
如
如果出现以下画面则说明安装成功。
It works!
3) jakarta-tomcat-6.0.14.tar.gz
#tar zxvf jakarta-tomcat-6.0.14.tar.gz
#cp –r jakarta-tomcat-6.0.14 /usr/local/tomcat
#/usr/local/tomcat/bin/startup.sh
打开 验证tomcat可以启动
4) 整和apache和tomcat
tomcat-connectors-1.2.19-src.tar.gz
#tar zxvf tomcat-connectors-1.2.19-src.tar.gz
进行编译配置。大家一定要注意这几个参数中前三个是很重要的,必要时可以去相应的目录看看相关的文件是否存在。
#cd tomcat-connectors-1.2.19-src/native
# ./ buildconf.sh
#./configure --with-apxs=/usr/local/apache/bin/apxs --with-tomcat=/usr/local/tomcat --with-java-home=/usr/java/jdk --with-jni
# make
# make install
#ll /usr/local/apache/modules/mod_jk.so
-rwxr-xr-x 1 root root 487769 8月 14 20:40 /usr/local/apache/modules/mod_jk.so
mod_jk.so生成成功了。
编辑apache的配置文件:
#vi /usr/local/apache/conf/httpd.conf
在末尾添加以下几行
# Load mod_jk module
LoadModule jk_module modules/mod_jk.so
# Where to find workers.properties
JkWorkersFile /usr/local/apache/conf/workers.properties
# Where to put jk logs
JkLogFile /usr/local/apache/logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the timestamp log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"
# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# Send servlet for context /examples to worker named worker1
#JkMount /examples/*.jsp worker1
JkMount /servlet/* worker1
# Send JSPs for context /examples to worker named worker1
JkMount /*.jsp worker1
创建文件workers.proferties
#vi /usr/local/apache/conf/workers.porperties
添加如下内容:
workers.tomcat_home=/usr/local/tomcat
workers.java_home=/usr/local/jdk
ps=/
worker.list=worker1
worker.worker1.port=8009
worker.worker1.host=localhost
worker.worker1.type=ajp13
worker.worker1.connection_pool_timeout=600
worker.worker1.socket_keepalive=1
worker.worker1.lbfactor=1
worker.inprocess.stdout=$(workers.tomcat_home)$(ps)logs$(ps)inprocess.stdout
worker.inprocess.stderr=$(workers.tomcat_home)$(ps)logs$(ps)inprocess.stderr
5) 配置apache和tomcat的虚拟主机
首先APACHE的虚拟主机设置如下:
修改 conf/httpd.conf找到
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf
修改为
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
然后编辑
conf/extra/httpd-vhosts.conf
加入下面的代码
ServerAdmin oasis.yan@intermobiz.com
DocumentRoot /data/www/test1
ServerName test1.ydjxc.com
DirectoryIndex index.jsp
ErrorLog logs/web_error_log
CustomLog logs/web_access_log common
Options -Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
ServerAdmin oasis.yan@intermobiz.com
DocumentRoot /data/www/test2
ServerName test2.ydjxc.com
ServerAlias localhost
DirectoryIndex index.jsp
ErrorLog logs/wap_error_log
CustomLog logs/wap_access_log common
Options -Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
备注:test1/index.jsp的内容如下:
<%@ page contentType="text/html; charset=gb2312" language="java"%>
<%
out.println("test1文件执行成功!");
%>
同理为test2/index.jsp
注意:丢掉下面这段代码会提示403错误
Options -Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
其次Tomcat设置虚拟主机
编辑tomcat的配置文件server.xml
在后面添加如下代码
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
prefix="access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
prefix="access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
备注:其中这是两段虚拟主机的代码,红色部分为虚拟目录的配置,这样就可以访问
特别注意的地方:
在配置文件中找到:
讲其改为:
如果不改的话,输入:就可以直接进入tomcat的管理界面了。
最后重新启动tomcat和apache,我们的安装就完成了
#/usr/local/tomcat/bin/shutdown.sh //关闭tomcat
#/usr/local/tomcat/bin/startup.sh //启动tomcat
#/usr/local/apache/bin/apachectl restart //重启apache