在apache与tomcat中配置虚拟目录与虚拟主机的方法 一,配置tomcat虚拟目录
1、 打开$tomcat_home$/conf/server.xml, 在<Host>和</host>之间加上
2、在$tomcat_home$/conf/catalina/localhost目录下会生成相应的配置文件,因此可以直接在$tomcat_home$/conf/catalina/localhost目录下写配置文件文件名任意取,最好是与web应用相同便于管理,如site.xml内容同上 二,添加tomcat虚拟主机
打开$tomcat_home$/conf/server.xml,在</host>后面添加:
<Host name="mybus.itnetcn.com" debug="0" appBase="/usr/etc" unpackWARs="true" autoDeploy="true">
<Logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="mybus_log." suffix=".txt" timestamp="true"/> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="mybus_access_log." suffix=".txt" pattern="common" resolveHosts="false"/> <Context path="" docBase="/usr/etc/MyBus/" debug="0" reloadable="true" crossContext="true"></Context>
</Host>说明:name为主机名,appBase为应用程序目录,docBase为网站根目录
三,apache添加虚拟目录
Alias /mybus/ "/usr/tomcat6/webapps/MyBus/"
<Directory "/usr/tomcat6/webapps/MyBus/"> Options None AllowOverride None Order allow,deny Allow from all </Directory>
四,apache 添加虚拟主机
<VirtualHost *:80>
<VirtualHost *:80>
#RewriteCond %{HTTP_HOST} ^([0-9a-zA-Z]+)\.openid\.mybus\.jbxue\.com/?$
RewriteCond %{HTTP_HOST} ^([0-9]+)\.jbxue\.com/?$
RewriteCond %{HTTP_HOST} ^(wap)\.itnetcn\.com/?$
RewriteCond %{HTTP_HOST} ^(club|mall|fair|news)\.itnetcn\.com/?$ </VirtualHost> (责任编辑:IT) |