最为完美的Tomcat+apache+php+jk2配置 (04/01/12更新)
发表于:2007-05-25来源:作者:点击数:
标签:
这是在下在这一段时间配置积累下的一点经验, 测试 是绝对通过的了,我用的 服务器 是RedHat Linux AS3.0,服务器在安装时没有安装这些软件,如果你先前安装得有这些,请先卸掉后再装,我想在Redhat9.0,8.0应该没有问题吧,不过需要大家测试一下! 1、安装JDK
这是在下在这一段时间配置积累下的一点经验,
测试是绝对通过的了,我用的
服务器是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-a
clearcase/" target="_blank" >ccess_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>
8)、server.xml 的配置
<Server port="8005" shutdown="SHUTDOWN" de
bug="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
UserDatabaseRe
alm 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://dev.6066.com/
上面有更详细的说明
chentian 回复于:2004-01-05 00:29:57
|
老大的帖子的目的就是为了让您的论坛多有些注册人数么?
还是让guest用户也能浏览您论坛上面的帖子吧
|
feiyi 回复于:2004-01-05 14:34:21
|
其实这里已经介绍得非常清楚了,只是他们不支持Html格式的浏览,比如那些标红什么的,就看不清楚了,所以就只能在我的论坛看了,请理解,不过如果你要html格式的,我可以发给您哦!
|
dennis2 回复于:2004-01-05 15:31:08
|
/usr/local/apache/conf/workers2.properties 这个文件是不是贴重复了?
|
tsgx 回复于:2004-01-05 17:23:59
|
[quote:dab50f84b8="chentian"]老大的帖子的目的就是为了让您的论坛多有些注册人数么?
还是让guest用户也能浏览您论坛上面的帖子吧[/quote:dab50f84b8]别这样说
|
jhsea3do 回复于:2004-01-05 19:27:38
|
如果没有必要,还是不要装TOMCAT5
很多东西不能跑的!
|
laiquan 回复于:2004-01-07 22:08:57
|
我想要一份html各式的最好是 sun solaris sparc7下的文档
还有具体需要的软件及版本!我已经半个月了,闹不好这个了!
|
黑色 回复于:2004-01-12 12:03:23
|
可是我去www.apache.org捉下來的jakarta-tomcat-connectors-jk2-src-current.tar.gz裡面並沒有.so的module呀>_<
看了其它高手的文章,好像是要編譯過,才會有
可是,我編譯出來沒辦法生成.so的檔案,只有一堆.o的>_<
希望不吝指教一下
|
feiyi 回复于:2004-01-18 14:04:12
|
对的,这个地方有个編譯我忘了写,我现在已经把我的贴子修改了,您按那个做就可以了,并且还把HTML格式的文件上传上来了,你可以查看得更清楚!!
|
feiyi 回复于:2004-01-18 14:08:52
|
这是HTML格式的,由于ChinaUnix不支持Html格式,你把这个下载后,换成.html就可以查看了
[quote:1595b6ec2d="laiquan"]我想要一份html各式的最好是 sun solaris sparc7下的文档
还有具体需要的软件及版本!我已经半个月了,闹不好这个了![/quote:1595b6ec2d]
|
| feiyi 回复于:2004-01-18 14:09:59
| http://bbs.chinaunix.net/forum/uploadfile/a_46371074406132.jpg 这个路径访问来出来就是HTML格式的了呵呵
| feiyi 回复于:2004-04-27 13:01:14
| 这个配置最近又在9.0 8.0的机器上配置过,同样是没有问题的。
|
|
|
原文转自:http://www.ltesting.net
|