php+jsp的配置问题

czzw 2003-10-10 03:03:58
我现在配置PHP和Tomcat发现,如果Tomcat可以使用的话,则PHP不能使用,如果把httpd.conf里面关于tomcat的部分删除,则PHP可以正常工作,这是怎么回事?
另外,tomcat启动后,输入http://localhost则出现的是原来tomcat主目录里面的东西而不apache主目录的东西,是怎么回事?
...全文
44 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zykj_2000 2003-10-10
  • 打赏
  • 举报
回复
4.设置虚拟主机,让Apache自动控制html与jsp的解析: 打开C:\Apache2\conf\httpd.conf,在最后加入下面这段代码并保存。NameVirtualHost * (去掉注释)
<VirtualHost * >
ServerAdmin davisye@163.com //你的mail地址
DocumentRoot "C:\Tomcat4\webapps"
ServerName localhost //你的服务名,若你的机器有域名,设为域名,但现用本机作测试
ErrorLog logs/davisye_home_log.txt //错误日志,在C:\Apache2\logs下,可用其它任意名字
CustomLog logs/davisye_Custom_log.txt common //访问日志,在C:\Apache2\logs下,可用其它任意名字
<Location "/*.jsp">
JkUriSet worker ajp13:localhost:8009
</Location>
<Location "/examples/servlet/*"> // 如果想运行examples 下面的Servlet 请加上这一段,如果是实际开发可根据自已的Servlet路径进行设置
JkUriSet worker ajp13:localhost:8009
</Location>
</VirtualHost>
5.在C:\apache2\conf下新建文件:workers2.properties,其下为内容:
# only at beginnin. In production uncomment it out
[logger.apache2]
level=DEBUG
[shm]
file=${serverRoot}/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:/*.jsp]
worker=ajp13:localhost:8009
(2)配置Tomcat4:
Tomcat端通过jk2.properties文件使用JK2。在[Tomcat_install_dir]/conf目录中已经有jk2.properties文件,用如下内容覆盖原内容:
# list of needed handlers.
handler.list=channelSocket,request
# Override the default port for the channelSocket
channelSocket.port=8009
五、全线测试:
在地址栏中输入http://localhost/ 如果可以运行Tomcat 下的Examples ,那恭喜你,Apache2与Tomcat4整合成功了!!!
六、虚拟主机的配置
(1) Apache 配置(httpd.conf)
1、NameVirtualHost *
2、虚拟主机设置
<VirtualHost * >
ServerAdmin davisye@163.com //你的mail地址
DocumentRoot "C:\project\XXX" //项目的根目录
ServerName www.xxx.com //域名
ErrorLog logs/xxx_home_log.txt //错误日志,在C:\Apache2\logs下,可用其它任意名字
CustomLog logs/xxx_log.txt common //访问日志,在C:\Apache2\logs下,可用其它任意名字
<Location "/*.jsp">
JkUriSet worker ajp13:localhost:8009
</Location>
<Location "/servlet/*"> // Servlet路径
JkUriSet worker ajp13:localhost:8009
</Location>
</VirtualHost>
3、workers2.properties 设置,(最好把以前的[uri./*.jsp]去掉)
[uri:www.xxx.com/*.jsp]
worker=ajp13:localhost:8009
4、Tomcat 配置 (servet.xml),在</host> 后面加上
<Host name="www.xxx.com" debug="0" appBase="C:\project\XXX" unpackWARs="true" autoDeploy="true">
<Context path="" docBase="/" debug="1"/>
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="xxx_access_log." suffix=".txt"
pattern="common" resolveHosts="false"/>
</Host>
zykj_2000 2003-10-10
  • 打赏
  • 举报
回复
帮贴一下吧
测试环境:win2000 pro+apache2.0.47+tomcat4.1.24+jdk1.4

1.安装tomcat;
2.在tomcat/conf/目录下增加jk2.properties 内容如下:(更改目录路径)

##============================================================================================
## THIS FILE MAY BE OVERRIDEN AT RUNTIME. MAKE SURE TOMCAT IS STOPED

## WHEN YOU EDIT THE FILE.



## COMMENTS WILL BE _LOST_



## DOCUMENTATION OF THE FORMAT IN JkMain javadoc.



# Override the default port for the socketChannel

# channelSocket.port=8019

# Default:

# channelUnix.file=${jkHome}/work/jk2.socket

# Just to check if the the config is working

shm.file=c:/Apache Group/Apache2/logs/jk2.shm



# In order to enable jni use any channelJni directive

channelJni.disabled = 0

# And one of the following directives:



# apr.jniModeSo=/opt/apache2/modules/mod_jk2.so



# If set to inprocess the mod_jk2 will Register natives itself

# This will enable the starting of the Tomcat from mod_jk2

# apr.jniModeSo=inprocess 这句加上不行
#================================================================================================

3。安装apache。
4。修改apache下conf/httpd.conf:

增加:
LoadModule jk2_module libexec/mod_jk2.dll

Alias /examples "c:/tomcat/webapps/examples"

5。在apache目录下建立libexec目录,下载mod_jk2.dll 放进去。

6。在apache 的conf下增加workers2.properties 内容如下:

##================================================================================================
[logger]

level=DEBUG



[config:]

#file=${serverRoot}/conf/workers2.properties

file=c:/Apache Group/Apache2/conf/workers2.properties

debug=0

debugEnv=0



[uriMap:]

info=Maps the requests. Options: debug

debug=0



# Alternate file logger

#[logger.file:0]

#level=DEBUG

#file=${serverRoot}/logs/jk2.log



[shm:]

info=Scoreboard. Required for reconfiguration and status with multiprocess servers

file=${serverRoot}/logs/jk2.shm

size=1000000

debug=0

disabled=0



[workerEnv:]

info=Global server options

timing=1

debug=0

# Default Native Logger (apache2 or win32 )

# can be overriden to a file logger, useful

# when tracing win32 related issues

#logger=logger.file:0



[lb:lb]

info=Default load balancer.

debug=0



#[lb:lb_1]

#info=A second load balancer.

#debug=0



[channel.socket:localhost:8009]

info=Ajp13 forwarding over socket

debug=0

tomcatId=localhost:8009



#[channel.socket:localhost:8019]

#info=A second tomcat instance.

#debug=0

#tomcatId=localhost:8019

#lb_factor=1

#group=lb

#group=lb_1

#disabled=0



#[channel.un:/opt/33/work/jk2.socket]

#info=A second channel connecting to localhost:8019 via unix socket

#tomcatId=localhost:8019

#lb_factor=1

#debug=0



[channel.jni:jni]

info=The jni channel, used if tomcat is started inprocess



[status:]

info=Status worker, displays runtime informations



[vm:]

info=Parameters used to load a JVM in the server process

#JVM=C:\jdk\jre\bin\hotspot\jvm.dll

OPT=-Djava.class.path=c:/tomcat/bin/tomcat-jni.jar;c:/tomcat/server/lib/commons-logging.jar

OPT=-Dtomcat.home=${TOMCAT_HOME}

OPT=-Dcatalina.home=${TOMCAT_HOME}

OPT=-Xmx128M

#OPT=-Djava.compiler=NONE

disabled=0



[worker.jni:onStartup]

info=Command to be executed by the VM on startup. This one will start tomcat.

class=org/apache/jk/apr/TomcatStarter

ARG=start

disabled=0

stdout=c:/Apache Group/Apache2/logs/stdout.log

stderr=c:/Apache Group/Apache2/logs/stderr.log



[worker.jni:onShutdown]

info=Command to be executed by the VM on shutdown. This one will stop tomcat.

class=org/apache/jk/apr/TomcatStarter

ARG=stop

disabled=0



[uri:/jkstatus/*]

info=Display status information and checks the config file for changes.

group=status:



#[uri:127.0.0.1:8003]

#info=Example virtual host. Make sure myVirtualHost is in /etc/hosts to test it

#alias=myVirtualHost:8003



#[uri:127.0.0.1:8003/ex]

#info=Example webapp in the virtual host. It'll go to lb_1 ( i.e. localhost:8019 )

#context=/ex

#group=lb_1



[uri:/examples]

info=Example webapp in the default context.

context=/examples

debug=0



#[uri:/examples1/*]

#info=A second webapp, this time going to the second tomcat only.

#group=lb_1

#debug=0



[uri:/examples/servlets/*]

info=Prefix mapping



[uri:/examples/*.jsp]

info=Extension mapping



[uri:/examples/*]

info=Map the whole webapp



[uri:/examples/servlets/HelloW]

info=Exampel with debug enabled.

debug=10

##=======================================================================================================

7。调试,启动apache,了;浏览http://hans:82/examples/ 看到tomcat下的内容,成功!

8。如果不想用examples,想自己新建自己的项目目录,则:
加入自己的项目 :
a.在SERVER.XML中加入:

<!-- Tomcat hans Context ; hans add it-->
<Context path="/hans" docBase="hans"
debug="0" privileged="true"/>


b.在HTTP.CONF中加入:
Alias /hans "c:/tomcat/webapps/hans"

c.在workers2.properties中加入:

##==============================hans add for a new perject=========
[uri:/hans]

info=Example webapp in the default context.

context=/hans

debug=0


[uri:/hans/servlets/*]

info=Prefix mapping



[uri:/hans/*.jsp]

info=Extension mapping



[uri:/hans/*]

info=Map the whole webapp



[uri:/hans/servlets/HelloW]

info=Exampel with debug enabled.

debug=10


#==========================================##

就可以了。
myblessu 2003-10-10
  • 打赏
  • 举报
回复
整合:
http://expert.csdn.net/Expert/topic/2177/2177780.xml?temp=.4848596

虚拟主机设置:
http://expert.csdn.net/Expert/topic/2145/2145316.xml?temp=.3123133

24,923

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Apache
社区管理员
  • Apache
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧