linux服务器apache 一个IP,一个端口,建立多个网站的方法。
Posted 西瓜一号
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux服务器apache 一个IP,一个端口,建立多个网站的方法。相关的知识,希望对你有一定的参考价值。
找到apache-tomcat-6.0.14\conf\server.xml ,再services 后面添加此段代码:
Xml代码
<!-- 此处 新增的项目配置-->
<Service name="pro">
<Connector port="8090" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8444" />
<Connector port="9999" protocol="AJP/1.3" redirectPort="8444" />
<Engine name="pro" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
<Context docBase="D:/pro/WebRoot" path="" />
</Host>
</Engine>
</Service>
<!-- 此处 新增的项目配置-->
<Service name="pro">
<Connector port="8090" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8444" />
<Connector port="9999" protocol="AJP/1.3" redirectPort="8444" />
<Engine name="pro" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
<Context docBase="D:/pro/WebRoot" path="" />
</Host>
</Engine>
</Service>
以上D:/pro/WebRoot 是我的工程webRoot 路径,大家可自己修改,另pro 也是自定义的。
具体全文如下:
Xml代码
<?xml version=‘1.0‘ encoding=‘utf-8‘?>
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JasperListener" />
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<!-- 以上为默认的配置 -->
<!-- 此方法为默认的配置方式-->
<Service name="Catalina">
<Connector port="8008" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host>
</Engine>
</Service>
<!-- 此处 新增的项目配置-->
<Service name="pro">
<Connector port="8090" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8444" />
<Connector port="9999" protocol="AJP/1.3" redirectPort="8444" />
<Engine name="pro" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
<Context docBase="D:/pro/WebRoot" path="" />
</Host>
</Engine>
</Service>
</Server>
<?xml version=‘1.0‘ encoding=‘utf-8‘?>
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JasperListener" />
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<!-- 以上为默认的配置 -->
<!-- 此方法为默认的配置方式-->
<Service name="Catalina">
<Connector port="8008" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host>
</Engine>
</Service>
<!-- 此处 新增的项目配置-->
<Service name="pro">
<Connector port="8090" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8444" />
<Connector port="9999" protocol="AJP/1.3" redirectPort="8444" />
<Engine name="pro" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
<Context docBase="D:/pro/WebRoot" path="" />
</Host>
</Engine>
</Service>
</Server>
以上是关于linux服务器apache 一个IP,一个端口,建立多个网站的方法。的主要内容,如果未能解决你的问题,请参考以下文章
Apache的网站,使用Nginx进行反向代理(1个IP绑定多个域名,对应多个网站)解决方案
企业常用Centos 7.4 --虚拟主机基于域名,端口,IP,Apache访问控制