这是在下在这一段时间配置积累下的一点经验,测试是绝对通过的了,我用的服务器是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-aclearcase/" 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>
、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
上面有更详细的说明