- 论坛徽章:
- 0
|
Apache+tomcat+jdk+jk安装
一. 下载软件:
下载apache:
http://httpd.apache.org/download.cgi
下载tomcat:
http://jakarta.apache.org/site/binindex.cgi
下载jdk:
http://java.sun.com/j2se/downloads/index.html
下载jk:
http://jakarta.apache.org/site/binindex.cgi
sco unix下载:
HTTP: http://www.sco.com/download
FTP: ftp://ftp.sco.com/pub/openserver5
二. 安装配置apache
安装:略
配置:
1. 编辑./conf/httpd.conf文件
windows加入:
LoadModule vhost_alias_module modules/mod_vhost_alias.so(去掉#号)
LoadModule jk2_module modules/mod_jk2.so
DirectoryIndex index.html index.html.var index.htm index.jsp(原有补充)
DefaultLanguage .zh-cn(原有修改)
AddDefaultCharset GB2312(原有修改)
NameVirtualHost 192.168.1.122:80
<Directory ~ "/WEB-INF/">; (代替workers2.properties文件中uri和worker)
Order allow,deny
Deny from all
</Directory>;
<VirtualHost 192.168.1.152:80>;
ServerAdmin jiupima@163.com
DocumentRoot "D:/web/Tomcat 5.0/webapps/sh_abc"
ServerName www.sh_abc.com(无域名服务直接加ip地址)
ErrorLog logs/ sh_abc.com-error_log
CustomLog logs/ sh_abc.com-access_log common
<Location "/*.jsp">;(用ajp13协议将*.jsp文件交由tomcat处理)
JkUriSet worker ajp13:localhost:8009
</Location>;
</VirtualHost>;
Sco unix加入:
LoadModule vhost_alias_module libexec/mod_vhost_alias.so(去掉#号)
LoadModule jk_module libexec/mod_jk.so(sco507下屏蔽conf/cf.d/tomcat文件中已有配置)
AddModule mod_jk.c (sco507下屏蔽conf/cf.d/tomcat文件中已有配置)
DirectoryIndex index.html index.htm index.jsp(原有补充)
NameVirtualHost 192.168.1.122:80
<VirtualHost 192.168.1.122:80>;
ServerAdmin jiupima@163.com
DocumentRoot "/usr/lib/apache/tomcat/webapps/sh_abc"
ServerName www.sh_abc.com(无域名服务直接加ip地址)
ErrorLog logs/ sh_abc.com-error_log
CustomLog logs/ sh_abc.com-access_log common
</VirtualHost>;
include /usr/lib/apache/conf/cf.d/tomcat
2. 编辑workers2.properties文件(windows下)
[shm]
file=D:\web\apache\Apache2\logs\shm.file
size=1048576
[channel.socket]
port=8009
host=127.0.0.1
[ajp13]
channel=channel.socket:localhost:8009
[uri:/sh_abc/*]
worker=ajp13:localhost:8009
3. 编辑/conf/cf.d/tomcat文件(unix下)
# Update this path to match your conf directory location
JkWorkersFile /usr/lib/apache/tomcat/conf/workers.properties
# the /sh_abc context
Alias /sh_abc "/usr/lib/apache/tomcat/webapps/sh_abc"
<Directory "/usr/lib/apache/tomcat/webapps/sh_abc">;
Options Indexes FollowSymLinks
</Directory>;
# Send everything for context /sh_abc to worker named worker1 (ajp13)
JkMount /*.jsp worker1(支持输入:http://ip)
JkMount /init_servlet worker1
JkMount /trad_servlet worker1
JkMount /mid_servlet worker1
JkMount /sh_abc/*.jsp worker1(支持输入:http://ip/sh_abc)
JkMount /sh_abc/init_servlet worker1
JkMount /sh_abc/trad_servlet worker1
JkMount /sh_abc/mid_servlet worker1
# The following line prohibits users from directly accessing WEB-INF
<Location ~ "/WEB-INF/">;
AllowOverride None
deny from all
</Location>;
三. 安装配置tomcat
安装:略
配置:
1. 先安装jdk。
2. 编辑server.xml文件
在<Host/>;中加入:
<Context path="/sh_abc" docBase="sh_abc" debug="0"
reloadable="true" crossContext="true"/>;
<Context path="" docBase="sh_abc" debug="0"
reloadable="true" crossContext="true"/>;
3. 编辑jk2.properties文件
handler.list=channelSocket,request
channelSocket.port=8009
4. 编辑workers.properties文件(unix下,一般用默认值)
四. 安装配置jdk
安装:略
配置:略
五. 安装配置jk
安装:略
配置:
1. 拷贝mod_jk.so(mod_jk2.so)到apache的libexec(modules)目录下
2. 在apache的httpd.conf中加入mod_jk.so(mod_jk2.so)
3. 编辑tomcat的jk2.properties文件
4. 编辑apache的workers2.properties文件(windows下)
5. 编辑apache的/conf/cf.d/tomcat文件(unix下)
六. 环境配置
windows:在“系统属性”里面->;“高级”->;点“环境变量”按钮,如果你希望所有用户都能用,就建立在“系统变量”里面,点“新建”按钮,变量名是 “JAVA_HOME”,变量值是你安装java的路径 D:\web\java\jdk1.5.0 ,然后编辑path变量,在变量值最后加上;%JAVA_HOME%\bin
sco unix:编辑.profile文件
JAVA_HOME=/usr/java
CATALINA_HOME=/usr/lib/apache
PATH=$ JAVA_HOME /bin CATALINA_HOME/bin ATH
export JAVA_HOME CATALINA_HOME PATH
七. Sco unix 下服务自启动与停止配置
自启动编辑文件/etc/rc2.d/S99WEBSERV(文件名自定义)
JAVA_HOM=/usr/java
CATALINA_HOME=/usr/lib/apache/tomcat
/usr/lib/apache/bin/apachectl start
/usr/lib/apache/tomcat/bin/startup.sh
echo "apache tomcat has been started !"
自停止编辑文件/etc/rc0.d/P99WEBSERV(文件名自定义)
JAVA_HOMa=/usr/java
CATALINA_HOME=/usr/lib/apache/tomcat
/usr/lib/apache/bin/apachectl stop
/usr/lib/apache/tomcat/bin/shutdown.sh
echo "apache tomcat has been stoped !"
一般格式
su - 用户名 –c “命令”
八. 其它问题
sco 507中不能启动apache
报错Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName,原因是/etc/hosts和/etc/hosts.equiv文件中主机域名与apache主机域名不同导致取不到ip,在logs中查看主机域名
报错Syntax error on line 1110 of /usr/lib/apache/conf/cf.d/httpd.conf:Invalid command 'JkUriSet', perhaps mis-spelled or defined by a module not included in the server configuration,原因未知,httpd.conf中去除行JkUriSet worker ajp13:localhost:8009
报错module mod_jk.c is already added, skipping,去除conf/cf.d/tomcat中加载mod_jk.so和mod_jk.c两行,移到conf/httpd.conf中加载即可
tomcat显示中文问题,在jsp文件中加入一行:<%@ page contentType="text/html;charset=gb2312" %>;即可。html文件显示中文加入<meta http-equiv="Content-Type" content="text/html; charset=gb2312">;不管用,需要apache显示,结合起来就没问题了。
sco507打了mp3包后,记不请是tomcat还是apache的配置文件上有个错误,好像是拼写错误,我改了后来又忘了在什么地方
九. 自动保持常启动状态
脚本如下:
str=’ps –ef | grep 程序名’
if [ “x$str” = “x” ]
then echo “程序名 错误 !”
su - 用户名 –c “程序名”
else echo “程序名 正常 !”
fi
在root用户的 crontab 序列中加入:0 0 * * * /u/用户名/脚本程序.sh |
|