分享
 
 
 

最为完美的Tomcat+apache+php+jk2配置

王朝php·作者佚名  2008-05-18
窄屏简体版  字體: |||超大  

这是在下在这一段时间配置积累下的一点经验,测试是绝对通过的了,我用的服务器是RedHat Linux AS 3.0,服务器在安装时没有安装这些软件,如果你先前安装得有这些,请先卸掉后再装 ,我想在Redhat 9.0,8.0 应该没有问题吧,不过需要大家测试一下!

1、安装JDK

1)、从sun上载最新jdk,正常的安装

./j2sdk-1_4_2_03-linux-i586.bin

rpm -ivh j2sdk-1_4_2_03-linux-i586.rpm

2)、为了以后升级方便,最好建一个软连接, 命令:ln -s /usr/java/j2sdk-1_4_2_03 /usr/local/jdk

2、安装Apache

1). 下载最新的:

http://www.apache.org/dist/httpd/httpd-2.0.47.tar.gz

2). 解包:

tar xvfz httpd-2.0.47.tar.gz

3). 安装:

cd httpd-2.0.47

./configure --prefix=/usr/local/apache --enable-so

make

make install

4). 修改httpd.conf:

vi /usr/local/apache/conf/httpd.conf

DirectoryIndex后加上index.php

加一行 AddType application/x-httpd-php .php .phtml .php3 .inc

加一行 LoadModule php4_module modules/libphp4.so (如果后面要安装最新php,它会自动来加上这个,如果您不安装php那么这个也就不要加上,要不会报错的哦)

AddDefaultCharset后改为GB2312

5). 启动时运行:

vi /etc/rc.d/rc.local 加一行 /usr/local/apache/bin/apachectl start

3、安装Mysql

1)、下载最新的安装包,请最好安装RPM包,这样最方便,又好用,我安的是这两个包MySQL-server-4.0.13-0.i386.rpm MySQL-client-4.0.13-0.i386.rpm,请从mysql.com上面下载。

2)、rpm -ivh MySQL-server-4.0.13-0.i386.rpm

rpm -ivh MySQL-client-4.0.13-0.i386.rpm

4、安装Php

1). 下载最新的:

http://www.php.net/get/php-4.3.4.tar.gz/from/this/mirror

2). 解包:

tar xvfz php-4.3.4.tar.gz

3). 安装:

cd php-4.3.4

./configure --with-mysql --with-apxs2=/usr/local/apache/bin/apxs --enable-track-vars --with-gd --with-zlib --with-xml

make

make install

cp php.ini-dist /usr/local/lib/php.ini

5、安装Tomcat 5

1)、下载最新的tomcat 5 http://www.apache.org/dist/jakarta/tomcat-5/v5.0.16/bin/jakarta-tomcat-5.0.16.tar.gz

2)、解包 tar xvfz jakarta-tomcat-5.0.16.tar.gz

3)、 mv jakarta-tomcat-5.0.16 /usr/local/

ln -s /usr/local/jakarta-tomcat-5.0.16 /usr/local/tomcat/

vi /usr/local/tomcat/bin/catalina.sh (操作时请注意备份哦)

打开catalina.sh后,在第三行后插入这几行:

JAVA_HOME=/usr/local/jdk/

CATALINA_HOME="/usr/local/tomcat/"

JAVA_OPTS="-Xms256m -Xmx256m"

然后存盘退出。

4)、现在你可以使用/usr/local/tomcat/bin/startup.sh /usr/local/tomcat/bin/shutdown.sh 来启动或停止tomcat服务了

5)、groupadd tomcat

useradd -g tomcat -c "Tomcat User" -d /usr/local/tomcat tomcat

passwd tomcat

chown -R tomcat:tomcat /usr/local/tomcat

chown -R tomcat:tomcat /usr/local/jakarta-tomcat-5.0.16

6). 启动时运行:

vi /etc/rc.d/rc.local 加一行 su - tomcat -c /usr/local/tomcat/bin/startup.sh

6、安装JK2 (这是比较重要的东东,看清楚哦,这里最容易出问题了)

1)、下载最新的JK2 http://www.apache.org/dist/jakarta/tomcat-connectors/jk2/jakarta-tomcat-connectors-jk2-src-current.tar.gz

2)、解包 tar xvfz jakarta-tomcat-connectors-jk2-src-current.tar.gz

3)、

cd jakarta-tomcat-connectors-jk2/jk/native

./buildconf.sh

./configure --with-apxs2=/usr/local/apache/bin/apxs

make

make install

cp jk/build/jk2/apache2/mod_jk2.so /usr/local/apache/modules

cp jk/build/jk2/apache2/jkjni.so /usr/local/apache/modules

4)、把mod_jk2加入 httpd.conf中 vi /usr/local/apache/conf/httpd.conf

LoadModule jk2_module modules/mod_jk2.so

5)、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

6)、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:128.100.1.49/*.jsp]

worker=ajp13:localhost:8009

[uri:www.lawcn.cn/*.jsp]

worker=ajp13:localhost:8009

[uri:www.friendlist.cn/*.jsp]

worker=ajp13:localhost:8009

[uri:www.cnho.com/*.jsp]

worker=ajp13:localhost:8009

# 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:128.100.1.49/*.jsp]

worker=ajp13:localhost:8009

[uri:www.lawcn.cn/*.jsp]

worker=ajp13:localhost:8009

[uri:www.friendlist.cn/*.jsp]

worker=ajp13:localhost:8009

[uri:www.cnho.com/*.jsp]

worker=ajp13:localhost:8009

7)http.conf 虚拟主机配置部分

#…………

#不相关的部分已经省略

NameVirtualHost *

<VirtualHost *>

ServerAdmin support@cnho.com

DocumentRoot /www/ebuddylist/web-4sx593/

ServerName www.friendlist.cn

ServerAlias *.friendlist.cn friendlist.cn ebuddylist.com *.ebuddylist.com

ErrorLog logs/www.friendlist.cn-error_log

CustomLog logs/www.friendlist.cn-access_log common

Options None

</VirtualHost>

<VirtualHost *>

ServerAdmin support@cnho.com

DocumentRoot /www/cnho/html/

ServerName www.cnho.com

ServerAlias *.cnho.com cnho.com

ErrorLog logs/www.cnho.com-error_log

CustomLog logs/www.cnho.com-access_log common

Options None

</VirtualHost>

<VirtualHost *>

ServerAdmin support@cnho.com

DocumentRoot /www/lawcn/asdf-web/

ServerName www.lawcn.cn

ServerAlias *.lawcn.cn lawcn.cn

ErrorLog logs/lawcn.cn-error_log

CustomLog logs/lawcn.cn-access_log common

Options None

<Location "/*.jsp">

JkUriSet worker ajp13:localhost:8009

</Location>

</VirtualHost>

、server.xml 的配置

<Server port="8005" shutdown="SHUTDOWN" debug="0">

<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"

debug="0"/>

<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"

debug="0"/>

<!-- Global JNDI resources -->

<GlobalNamingResources>

<!-- Test entry for demonstration purposes -->

<Environment name="simpleValue" type="java.lang.Integer" value="30"/>

<!-- Editable user database that can also be used by

UserDatabaseRealm to authenticate users -->

<Resource name="UserDatabase" auth="Container"

type="org.apache.catalina.UserDatabase"

description="User database that can be updated and saved">

</Resource>

<ResourceParams name="UserDatabase">

<parameter>

<name>factory</name>

<value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>

</parameter>

<parameter>

<name>pathname</name>

<value>conf/tomcat-users.xml</value>

</parameter>

</ResourceParams>

</GlobalNamingResources>

<Service name="Catalina">

<!-- Define a non-SSL Coyote HTTP/1.1 Connector on port 8080 -->

<Connector port="8080"

maxThreads="150" minSpareThreads="25" maxSpareThreads="75"

enableLookups="false" redirectPort="8443" acceptCount="100"

debug="0" connectionTimeout="20000"

disableUploadTimeout="true" />

<!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->

<Connector port="8009"

enableLookups="false" redirectPort="8443" debug="0"

protocol="AJP/1.3" />

<!-- Define the top level container in our container hierarchy -->

<Engine name="Catalina" defaultHost="localhost" debug="0">

<!-- Global logger unless overridden at lower levels -->

<Logger className="org.apache.catalina.logger.FileLogger"

prefix="catalina_log." suffix=".txt"

timestamp="true"/>

<!-- Because this Realm is here, an instance will be shared globally -->

<!-- This Realm uses the UserDatabase configured in the global JNDI

resources under the key "UserDatabase". Any edits

that are performed against this UserDatabase are immediately

available for use by the Realm. -->

<Realm className="org.apache.catalina.realm.UserDatabaseRealm"

debug="0" resourceName="UserDatabase"/>

<Host name="localhost" debug="0" appBase="webapps"

unpackWARs="true" autoDeploy="true"

xmlValidation="false" xmlNamespaceAware="false">

<Logger className="org.apache.catalina.logger.FileLogger"

directory="logs" prefix="localhost_log." suffix=".txt"

timestamp="true"/>

<!-- Tomcat Root Context -->

<!--

<Context path="" docBase="ROOT" debug="0">

-->

</Host>

<Host name="www.lawcn.cn" debug="0" appBase="webapps"

unpackWARs="true" autoDeploy="true"

xmlValidation="false" xmlNamespaceAware="false">

<Logger className="org.apache.catalina.logger.FileLogger"

directory="logs" prefix="lawcn_log." suffix=".txt"

timestamp="true"/>

<Context path="" docBase="lawcn" debug="0" />

</Host>

</Engine>

</Service>

</Server>

如果你还有问题请来信告之,或上我的论坛

http://bbs.6066.com/list.asp?boardid=29

上面有更详细的说明

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有