CSDN博客

img echoguo

tomcat 5.0 + apache 2.0 完全安装

发表于2004/9/24 17:23:00  979人阅读

服务器环境:

RedHat Linux 8.0
J2sdk1.4.1_02
Tomcat 5.0.12 binary
Apache 2.0.47 built from source
jk2 connector source from jakarta.apache.org

安装JDK:

下载: j2sdk-1_4_1_02-linux-i586.bin
把jdk 安装在/usr/local/j2sdk1.4.1_02
在/usr/local 下建立 软连接 jdk
#ln -s /usr/local/j2sdk1.4.1_02 /usr/local/jdk

[user@host]# cat /etc/profile.d/java.sh
# set java environment
export JAVA_HOME=/usr/local/jdk
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=$JAVA_HOME/lib

#更改shell文件属性:
#chmod 755 /etc/profile.d/java.sh

#查看是否正确
#which java
/usr/local/jdk/bin/java


安装apache :

#cd /usr/local/src/
#tar -xzvf httpd-2.0.47.tar.gz
#cd httpd-2.0.47
#配置apache 支持动态module 加载
#./configure /
"--with-layout=Apache" /
"--prefix=/usr/local/apache" /
"--enable-module=so" /
"--enable-module=setenvif" /
"--enable-module=rewrite" /
"--with-mpm=prefork"

#make
#make install

#修改http.conf 具体的修改请参考apache2.0文档
# 或者查看 http://www.cnfug.org/journal/3/02.html

StartServers 10
MinSpareServers 25
MaxSpareServers 50
ServerLimit 2000
MaxClients 1500 #Apache可以同时处理的请求
MaxRequestsPerChild 10000



安装Php :
下载: php-4.3.3.tar.gz
#cd /usr/local/src
#tar -xzvf

#php for apache 以apache modules的方式运行
./configure --with-apxs2=/usr/local/apache/bin/apxs

#php run like shell 以单独的shell方式运行
./configure --prefix=/usr/local/php

#php for apache
./configure /
--with-apxs2=/usr/local/apache/bin/apxs /
--enable-track-vars /
--enable-debug /
--enable-url-includes /
--enable-sockets /
--with-config-file-path=/usr/local/apache/conf #php.ini文件放的目录
#下面的参数是安装PHP + gd库
--with-gd=/usr/local /
--enable-gd-native-ttf /
--with-ttf=/usr/local /
--with-jpeg-dir=/usr/local /
--with-zlib-dir=/usr/local /
--with-png-dir=/usr/local
#make
#make install
#ls -l /usr/local/apache/modules/libphp4.so #存在 安装成功

#修改apache http.conf
添加
LoadModule php4_module modules/libphp4.so
AddType application/x-httpd-php .php


安装Tomcat:
#cd /usr/local
#tar -xzvf jakarta-tomcat-5.0.12.tar.gz
#ln -s jakarta-tomcat-5.0.12 tomcat
#测试Tomcat正常安装:
#/usr/local/tomcat/bin/startup.sh

#通过IE http://yourIP:8080/ Tomcat的页面正常显示


安装JK2 :
#cd /usr/local/src
#tar -xzvf jakarta-tomcat-connectors-jk2-2.0.2-src.tar.gz
#cd jakarta-tomcat-connectors-jk2-2.0.2-src
#cd jk/native2
#chmod 755 buildconf.sh
#./configure --with-apxs2=/usr/local/apache/bin/apxs --enable-EAPI
#make
#make install
#如果make install 不成功需要手工发布mod_jk2.so
#cd /usr/local/src/jakarta-tomcat-connectors-jk2-2.0.2-src/jk/build/jk2/apache2
#cp *.so /usr/local/apache/modules/
配置$CATLINA/conf/server.xml









factory
org.apache.catalina.users.MemoryUserDatabaseFactory


pathname
conf/tomcat-users.xml


















#编辑
#vi /usr/local/tomcat/conf/jk2.properties
# list of needed handlers.
handler.list=channelSocket,request
# Override the default port for the channelSocket
channelSocket.port=8009


#编辑文件:

#vi /usr/local/apache/conf/workers2.properties

# only at beginnin. In production uncomment it out
[logger.apache2]
level=DEBUG

[shm]
file=/usr/local/apache/logs/shm.file
size=1048576

# Example socket channel, override 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:192.168.0.90/*.jsp]
worker=ajp13:localhost:8009



#编辑http.conf
#修改
DocumentRoot "/usr/local/tomcat/webapps"
#添加index.jsp
DirectoryIndex index.html index.html.var index.jsp


LoadModule jk2_module modules/mod_jk2.so


Order deny,allow
Deny from all

#
# Order deny,allow
# Deny from all
#


Order Allow,Deny



ServerName www.home.net
ServerAlias www
ServerAlias localhost
ServerAlias 192.168.0.90
ServerAdmin webmater@xxx.com
DocumentRoot /www

ErrorLog logs/home.net-errorlog
CustomLog logs/home.net-access.log common


JkUriSet worker ajp13:localhost:8009


#在配置server.xml 的时候:
#配置管理端口 和连接的端口顺序颠倒一下
#在 catalina.out 可以观察到:
#这样用apache 连接的时候,就不用等待了.






#修改:/usr/local/tomcat/conf/Catalina/localhost/manager.xml 相对路径改为绝对路径





#修改:/usr/local/tomcat/conf/Catalina/localhost/admin.xml 相对路径改为绝对路径




#修改: /usr/local/tomcat/conf/tomcat-users.xml 添加manager 和admin 角色












#可以通过http://URI:8080/manager/html http://URI:8080/admin/ 管理自己的服务

#TOMCAT 默人的默认ROOT 为它的 "http://URI/" webapps


TOMCAT 优化:

修改:
catalina.sh 设置:

JAVA_OPTS="-server -Xmx128m -Xms128m"

echo "Using CATALINA_BASE: $CATALINA_BASE"
echo "Using CATALINA_HOME: $CATALINA_HOME"
echo "Using CATALINA_TMPDIR: $CATALINA_TMPDIR"
echo "Using JAVA_HOME: $JAVA_HOME"
echo "Using JAVA_OPTS: $JAVA_OPTS



参数说明:

-server
Select the Java HotSpot Server VM.

-Xmsn
Specify the initial size, in bytes, of the memory allocation pool. This value must be a multiple of 1024 greater than 1MB. Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes. The default value is 2MB. Examples:
-Xms6291456
-Xms6144k
-Xms6m


-Xmxn
Specify the maximum size, in bytes, of the memory allocation pool. This value must a multiple of 1024 greater than 2MB. Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes. The default value is 64MB. Examples:
-Xmx83886080
-Xmx81920k
-Xmx80m


#在添加WEBAPP 的时候,需要建立WEB-INF/web.xml
#否则不能每次重新启动TOMCAT 的时候WEBAPP会丢失


阅读全文
0 0

相关文章推荐

img
取 消
img