|
Timeout Tutorial
花了一个下午的时间终于可以让我RH8.0的Apache能支持JSP/Servlet了,现在写下来与大家共享!
1. 下载所需包
http://jakarta.apache.org/builds/jakarta-tomcat-4.0/archives/v4.1.18/bin/jakarta-tomcat-4.1.18.tar.gz
http://jakarta.apache.org/builds/jakarta-tomcat-4.0/archives/v4.1.18/src/jakarta-tomcat-connectors-4.1.18-src.tar.gz
http://www.apache.org/dist/httpd/old/httpd-2.0.40.tar.gz
2. 解压下载的包
cd /tmp
tar xvzf jakarta-tomcat-4.1.18.tar.gz
tar xvzf jakarta-tomcat-connectors-4.1.18-src.tar.gz
tar xvzf httpd-2.0.40.tar.gz
mv jakarta-tomcat-4.1.18 /usr/local/tomcat
3. 编译安装http-2.0.40
cd /tmp/httpd-2.0.40
./configure --prefix=/usr/local/apache2 --enable-module=so
./make
./make install
4. 编译mod_jk.so模块
cd /tmp/jakarta-tomcat-connectors-4.1.18-src/jk/native
./buildconf.sh
./configure --with-apxs=/usr/local/apache2/bin/apxs
./make
完成好会在当前目录的apache-2.0下生成mod_jk.so,把它拷贝到/usr/lib/httpd/modules下
cp apache-2.0/mod_jk.so /usr/lib/httpd/modules/
5. 修改/usr/local/tomcat/conf/server.xml文件
(1)在<Host name="localhost" debug="0" appBase="webapps"
unpackWARs="true" autoDeploy="true">后面加入下面内容:
<Listener className="org.apache.ajp.tomcat4.config.ApacheConfig"
modJk="/usr/lib/httpd/modules/mod_jk.so" />
同时把上面localhost该成你自己的域名比如 name = "www.linuxfans.org"
(2)在<Server port="8005" shutdown="SHUTDOWN" debug="0">后面加入下面内容:
<Listener className="org.apache.ajp.tomcat4.config.ApacheConfig" append="true"
forwardAll="false" modJk="/usr/lib/httpd/modules/mod_jk.so"
workersConfig="/usr/local/tomcat/conf/jk/workers.properties" />
6. 在/usr/tomcat/conf/下面创建一个名叫一个目录却jk,并在这个目录下创建一个叫workers.properties的文件,其内容如下
worker.list=ajp13
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
7. 修改/etc/httpd/conf/httpd.conf
在Include conf.d/*.conf后加入下面这行:
Include /usr/local/tomcat/conf/auto/mod_jk.conf
8. 修改/usr/java/tomcat/conf/tomcat-usrs.xml,该完后如下:
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="tomcat"/>
<role rolename="role1"/>
<role rolename="manager"/>
<role rolename="admin"/>
<user uname="tomcat" password="tomcat" roles="tomcat"/>
<user uname="role1" password="tomcat" roles="role1"/>
<user uname="both" password="tomcat" roles="tomcat,role1"/>
<user uname="manager" password="manager" roles="manager"/>
<user uname="admin" password="admin" roles="admin"/>
</tomcat-users>
9.测试一下
启动Tomcat: /usr/local/tomcat/bin/startup.sh
重新启动httpd服务: /etc/init.d/httpd restart
因为tomcat启动比较慢,你可能要等一会儿!
在浏览器测试http://www.linuxfans.org:8080/examples和http://www.linuxfans.org/examples
如果没问题,那就搞定了!
同时你也可以用http://www.linuxfans.org/admin管理你的tomcat(用户名和口令有: admin/admin, 你可以通过修改tomcat-usrs.xml来设定自己的管理员用户和口令)
同上http://www.linuxfans.org/manager管理你的项目
(用户名和口令有: manager/manager, 你可以通过修改tomcat-usrs.xml来设定自己的管理员用户和口令)
参考文献
http://www.johnturner.com/howto/apache-tomcat-howto.html
有问题请恢复! |
|