一步一步教你如何在linux下配置apache+tomcat
2008-01-05 18:47:45 来源:WEB开发网——linux9+jdk1.4.2+apache2.0.48+tomcat4.1.29+jk2.0.2+MySQL4.0.16
一.安装前预备。
1. 所有组件都安装到/usr/local/e789目录下
2. 解压缩命令:tar —vxzf 文件名(.tar 或 .tar.gz)
3. 复制命令:cp 文件名 或cp —Rf 文件夹名
4. 删除命令:rm 文件名 或 rm —Rf 文件夹名
5. 编辑文件命令:vi 文件名 :q!不保存退出 :wq 保存退出
二.安装jdk 1.4.2
1. 执行二进制文件 ./j2sdk-1_4_2-linux-i586.bin 解压生成j2sdk1.4.2文件夹
2. 将文件夹改名为jdk142
3. 配置文件(设置环境变量):/etc/PRofile
java_HOME=/usr/local/e789/jdk142
eXPort JAVA_HOME
TOMCAT_HOME=/usr/local/e789/tomcat4129
export TOMCAT_HOME
CATALINA_HOME=/usr/local/e789/tomcat4129
export CATALINA_HOME
CATALINA_BASE=/usr/local/e789/tomcat4129
export CATALINA_BASE
APACHE_HOME=/usr/local/e789/apache2048
export APACHE_HOME
HTTPD_HOME=/usr/local/e789/apache2048
export HTTPD_HOME
CLASSPATH=/usr/local/e789/jdk142/lib:/usr/local/e789/jdk142/jre/lib
export CLASSPATH
PATH=$PAHT:/usr/local/e789/jdk142/bin:/usr/local/e789/jdk142/jre/bin
三.安装tomcat 4.1.29
1. 解压缩文件jakarta-tomcat-4.1.29.tar.gz
2. 将解压后的文件夹改名为tomcat4129
3. 启动(停止)命令:./bin/startup.sh (shutdown.sh)
4. 测试tomcat:在ie里输入http://(ip):8080,假如有内容出现,则说明安装成功
四.安装配置apache 2.0.48
1. 解压缩文件httpd-2.0.48.tar.gz
2. 安装:①./configure --with-layout=Apache
--prefix=/usr/local/e789/apache2048
--enable-module=so
--enable-mods-shared=most
--with-mpm=prefork
②make
③make install
3. 配置文件:/usr/local/e789/apache2048/conf/httpd.conf
DocumentRoot "/usr/local/e789/tomcat4129/webapps"(将发布的目录指向tomcat的webapps目录)
<Directory "/usr/local/tomcat4129/webapps">
4. 启动文件:./bin/httpd -k start (restart/stop)
5. 测试apache:在ie里输入http://(ip),假如有内容出现,则说明安装成功
五.安装jk2
1. 解压缩文件jakarta-tomcat-connectors-jk2-src-current.tar.gz
2. 将解压后的文件夹改名为jk202
3. 执行buildconf.sh文件。
4. 执行configure文件:
①./jk/native2/configure --with-apxs2=/usr/local/e789/apache2048/bin/apxs --enable-EAPI
--with-tomcat41=/usr/local/e789/tomcat4129
②make
③make install(我做的时候,这个命令不好用)
六.整和apache和tomcat
1. 把jkjni.so和mod_jk2.so文件复制到apache的modules目录下
cp /usr/local/e789/jk202/jk/build/jk2/apache2/*.so /usr/local/e789/apache2048/modules
2. 把jk2.properties文件复制到tomcat的conf目录下
cp /usr/local/e789/jk202/jk/conf/jk2.properties /usr/local/e789/tomcat4129/conf
3. 把worker2.properties文件复制到apache的conf目录下
cp /usr/local/e789/jk202/jk/conf/worker2.properties /usr/local/e789/apache2048/conf
4. 编辑jk2.properties文件
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
5. 编辑apache的http.conf
vi /usr/local/apache/conf/http.conf
LoadModule jk2_module modules/mod_jk2.so
DirectoryIndex index.Html index.html.var index.jsp
6. 编辑apache/conf/workers2.properties文件
# only at beginnin. In prodUCtion uncomment it out
[logger.apache2]
level=DEBUG
[shm]
file=/usr/local/apache/logs/jk2.shm
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:*.jsp]
worker=ajp13:localhost:8009
(负责把*.jsp的文件通过ajp13发送到tomcat处理)
7.编辑tomcat的server.xml
<!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
port="8009" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="10" debug="0" connectionTimeout="0"
useURIValidationHack="false"
protocolHandlerClassName="org.apache.jk.server.JKCoyoteHandler" />
<!-- 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"/>
8.启动tomcat和apache测试(先启动tomcat)
9.建立虚拟目录:
① 在tomcat/conf/server.xml文件中建立
<Host name=”10.4.0.33” debug=”0” appBase=”webapps”
unpackWARs=”true” autoDeploy=”true”
xmlValidation=”false” xmlNamespaceAware=”false”>
<Logger className=”org.apache.Catalina.logger.FileLogger”
directory=”logs” prefix=”filename_log” suffix=”.txt”
timestamp=”true” />
<context path=”/dirName” docBase=”/test/www/jsp” debug=”0”
reloadable=”true />
</Host>
docBase为真实目录
② 在apache/conf/workers2.properties文件中建立
[uri:/dirName/*.jsp]
work=ajp13:localhost:8009
七.安装mysql4.0.16
1. 解压缩文件:mysql-debug-4.0.16-pc-linux-i686.tar.gz
2. 将解压后的目录改为mysql4016
3. 建立用户:useradd –g root mysql
passwd –u mysql
4. 将mysql4016目录的拥有权改成 mysql 用户:chown –R mysql:root mysql4016
5. 在/usr/local下建立连接文件
ln –s /usr/local/e789/mysql4016 mysql
6. 以mysql用户的身份登陆,运行脚本来建立一个初始化数据库:
su mysql
./mysql4016/scripts/mysql_install_db
exit(回到root身份)
7. 把启动脚本程序复制到/etc/rc.d/init.d目录里
cd /etc/rc.d/init.d
cp /usr/local/mysql/support-files/mysql.server mysql
8. 运行chkconfig把MySQL添加到系统的启动服务组里面去
/sbin/chkconfig --
/sbin/chkconfig --add mysql
9. 测试mysql
启动:/etc/rc.d/init.d/mysql start
假如显示Starting mysqld daemon with databases from /var/lib/mysql 则成功
(/usr/local/mysql/bin/mysql为mysql客户端程序)
10.最后更改治理员密码
./bin/mysqladmin -u root passWord e789
11.登陆:mysql –u root –p e789
- ››linux下两台服务器文件实时同步方案设计和实现
- ››如何检查oracle的归档空间是否满了
- ››如何在浏览器中打开PDF文件并实现预览的思路与代码...
- ››如何改Win7系统我的文档保存位置
- ››Linux文件描述符中的close on exec标志位
- ››Linux下管道使用的一些限制
- ››Linux 误删/usr/bin 解决方法
- ››linux 添加新用户并赋予sudo执行权限
- ››linux常用软件安装方法
- ››Linux的分区已经被你从Windows中删除,系统启动后...
- ››linux enable命令大全
- ››Linux实现基于Loopback的NVI(NAT Virtual Interfa...
更多精彩
赞助商链接