Chinaunix首页 | 论坛 | 博客
  • 博客访问: 880199
  • 博文数量: 254
  • 博客积分: 5350
  • 博客等级: 大校
  • 技术积分: 2045
  • 用 户 组: 普通用户
  • 注册时间: 2008-06-27 13:27
文章分类

全部博文(254)

文章存档

2015年(1)

2014年(9)

2013年(17)

2012年(30)

2011年(150)

2010年(17)

2009年(28)

2008年(2)

分类: 系统运维

2011-04-14 17:25:52

Centos5 Apache2.2.6 PHP5 tomcat6.0.14 jdk1.6整合安装
安装步骤:
依照前人經驗,收集整理,并修復了幾處錯誤,歸納如下:

1.jdk-6u3-linux-i586.bin

#chmod u x jdk-6u3-linux-i586.bin
#./jdk-6u3-linux-i586.bin

ln -s /usr/local/jdk1.6.0_03 /usr/local/jdk
ln -s /usr/local/jdk1.6.0_03 /jre /usr/local/jre
#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/profile
java –version 查看jdk是否安装成功
2. httpd-2.2.6.tar.gz
#cp httpd-2.2.6.tar.gz /usr/local
#cd /usr/local
#tar zxvf httpd-2.2.6.tar.gz
#cd httpd-2.2.6
#./configure –prefix=/usr/local/apache --enable-module=so
#make
#make install
启动Apache,并测试。
# cd /usr/local/apache/bin
# ./apachectl start
打开浏览器,并在地址栏中输入主机的IP地址
3. apache-tomcat-6.0.14.tar.gz
#tar zxvf apache-tomcat-6.0.14.tar.gz
#cp –r apache-tomcat-6.0.14 /usr/local/tomcat
#/usr/local/tomcat/bin/startup.sh
打开

验证tomcat可以启动
整和apache和tomcat
4. tomcat-connectors-1.2.25-src.tar.gz
 注:使用2.0版的編譯后生成的mod_jk2.so文件,後面調用時會發生無法識別的命令錯誤。暫時不知道哪里出了問題
#tar zxvf tomcat-connectors-1.2.25-src.tar.gz
进行编译配置。大家一定要注意这几个参数中前三个是很重要的,必要时可以去相应的目录看看相关的文件是否存在。
#cd tomcat-connectors-1.2.25-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生成成功了。
或者:
 tar zxvf jakarta-tomcat-connectors-1.2.15-src.tar.gz
 cd jakarta-tomcat-connectors-1.2.15-src/native
./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


==================
增加,jakarta-tomcat-connectors-jk2-2.0.4-src.tar.gz 編譯安裝
之前,按照jk1的編譯方法,編譯出來的mod_jk2.so文件加載時總報錯誤mod_jk2.so: undefined symbol: jk_jni_status_code;在網上找了良久,也參考了官方文檔,終於有了正果。

安裝
tar zxvf jakarta-tomcat-connectors-jk2-2.0.4-src.tar.gz
cd jakarta-tomcat-connectors-jk2-2.0.4-src/jk/native2
./buildconf.sh
./configure --with-apxs2=/usr/local/apache/bin/apxs --with-apr-lib=/usr/local/apache/bin --with-jni
make jk2-build-apxs
cd server/apache2
make -f Makefile.apxs install

這樣就會自動在/usr/local/apache/modules下生成mod_jk2.so,jkjni.so模塊

修改http.conf文件,增加LoadModule jk2_module   modules/mod_jk2.so
運行apachectl -t ,測試成功。

在/usr/local/apache/conf/下創建workers2.properties文件,內容如下:
[root@ldapbak conf]# cat workers2.properties
[logger.apache2]
level=DEBUG
# Shared memory handling. Needs to be set.
[shm]
file=/usr/local/apache/logs/shm.file
size=1048576
# Example socket channel, explicitly set port and host.
[channel.socket:localhost:8009]
port=8009
host=127.0.0.1
# define the worker
[ajp13:localhost:8009]
channel=channel.socket:localhost:8009
#Uri mapping
[uri:/*.jsp]
[uri:/servlet/*]
[uri:/*.vm]
[uri:/*.do]
worker=ajp13:localhost:8009
group=ajp13:localhost:8009

修改文件
#vi /usr/local/apache/conf/httpd.conf 添加以下語句
JkSet config.file /usr/local/apache/conf/workers2.properties
保存,退出。
[root@ldapbak conf]# apachectl -t
[Fri Apr 15 17:14:30 2011] [notice] config.update(): done logger.apache2
[Fri Apr 15 17:14:30 2011] [notice] config.update(): done shm
[Fri Apr 15 17:14:30 2011] [notice] config.update(): done channel.socket:localhost:8009
[Fri Apr 15 17:14:30 2011] [notice] config.update(): done ajp13:localhost:8009
[Fri Apr 15 17:14:30 2011] [notice] config.update(): done uri:/*.jsp
[Fri Apr 15 17:14:30 2011] [notice] config.update(): done uri:/servlet/*
[Fri Apr 15 17:14:30 2011] [notice] config.update(): done uri:/*.vm
[Fri Apr 15 17:14:30 2011] [notice] uriEnv.setAttribute() the worker directive is deprecated. Use 'group' instead.
[Fri Apr 15 17:14:30 2011] [notice] config.update(): done uri:/*.do
Syntax OK
[root@ldapbak conf]# apachectl restart
輸入網址測試,成功!

====================

编辑apache的配置文件:
#vi /usr/local/apache/conf/httpd.conf 添加以下語句
在末尾添加以下几行
# Load mod_jk module
LoadModule jk_module modules/mod_jk.so
include conf/mod_jk.conf
mod_jk.conf文件內容如下:

# 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
加入下面的代码
NameVirtualHost *:80

ServerAdmin oasis.yan@intermobiz.com
DocumentRoot /data/www/test1
ServerName test1.ydjxc.com
ErrorLog logs/web_error_log
CustomLog logs/web_access_log common

Options  FollowSymLinks
DirectoryIndex index.jsp
AllowOverride None
Order allow,deny
Allow from all




ServerAdmin oasis.yan@intermobiz.com
DocumentRoot /data/www/test2
ServerName test2.ydjxc.com
ServerAlias localhost
ErrorLog logs/wap_error_log
CustomLog logs/wap_access_log common

Options  FollowSymLinks
DirectoryIndex index.jsp
AllowOverride None
Order allow,deny
Allow from all


备注:test1/index.jsp的内容如下:
[root@ldapbak jsp]# cat index.jsp



Now time is: <%=new java.util.Date()%>




同理为test2/index.jsp
注意:丢掉下面这段代码会提示403错误
Options -Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all

其次Tomcat设置虚拟主机
编辑tomcat的配置文件server.xml
區間內添加如下類似的代码,用于指定應用的主目錄


备注:其中这是两段虚拟主机的代码,红色部分为虚拟目录的配置,这样就可以访问



配置/usr/local/tomcat/conf/tomcat-users.xml,
按示例增加管理用戶名及密碼,權限設置,重啟服務。就可以輸入
點擊左邊管理就可以直接进入tomcat的管理界面了。

最后重新启动tomcat和apache,我们的安装就完成了
#/usr/local/tomcat/bin/shutdown.sh //关闭tomcat
#/usr/local/tomcat/bin/startup.sh //启动tomcat
#/usr/local/apache/bin/apachectl restart //重启apache

阅读(846) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~