在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
修改端口、修改默认发布目录、多域名绑定 复制代码 代码如下: <Connector port="8080" protocol="HTTP/1.1" maxThreads="150" connectionTimeout="20000" redirectPort="8443" /> <Connector port="8080" protocol="HTTP/1.1" maxThreads="150" connectionTimeout="20000" redirectPort="8443" /> 修改后: 复制代码 代码如下: <Connector port="80" protocol="HTTP/1.1" maxThreads="150" connectionTimeout="20000" redirectPort="8443" /> <Connector port="80" protocol="HTTP/1.1" maxThreads="150" connectionTimeout="20000" redirectPort="8443" /> 其实这里就是把port:8080,修改成port:80就可以了,其他的参数不变。这样客户机在访问服务器时直接输入IP或域名就可以了。 复制代码 代码如下: <Connector port="80" protocol="HTTP/1.1" maxThreads="150" connectionTimeout="20000" redirectPort="8443" /> <Connector port="80" protocol="HTTP/1.1" maxThreads="150" connectionTimeout="20000" redirectPort="8443" /> 修改后: 复制代码 代码如下: <Connector port="80" protocol="HTTP/1.1" maxThreads="150" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8"/> <Connector port="80" protocol="HTTP/1.1" maxThreads="150" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8"/> 三、修改tomcat发布路径(默认路径:E:\J2EEServer\Tomcat 6.0\webapps\ROOT) 复制代码 代码如下: <Engine name="Catalina" defaultHost="localhost"> <Host name="localhost" appBase="webapps" unpackWARs="true" xmlValidation="false" xmlNamespaceAware="false"> </Host> </Engine> <Engine name="Catalina" defaultHost="localhost"> <Host name="localhost" appBase="webapps" unpackWARs="true" xmlValidation="false" xmlNamespaceAware="false"> </Host> </Engine> 在<host></host>标签之间添加上: 复制代码 代码如下: <Context path="" docBase="photo" debug="0" reloadable="true" /> <Context path="" docBase="项目路径" debug="0" reloadable="true" /> path是说明虚拟目录的名字,如果你要只输入ip地址就显示主页,则该键值留为空; 复制代码 代码如下: <Engine name="Catalina" defaultHost="localhost"> <Host name="localhost" appBase="webapps" unpackWARs="true" xmlValidation="false" xmlNamespaceAware="false"> </Host> </Engine> <Engine name="Catalina" defaultHost="localhost"> <Host name="localhost" appBase="webapps" unpackWARs="true" xmlValidation="false" xmlNamespaceAware="false"> </Host> </Engine> 方案一:多个工程在不同的目录下 复制代码 代码如下: <Engine name="Catalina" defaultHost="pic.ogeek.net"> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> <Host name="xixi.ogeek.net" appBase="abcapps" unpackWARs="true" xmlValidation="false" xmlNamespaceAware="false"> </Host> <Engine name="Catalina" defaultHost="pic.ogeek.net"> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> <Host name="xixi.ogeek.net" appBase="abcapps" unpackWARs="true" xmlValidation="false" xmlNamespaceAware="false"> </Host> <Host name="haha.ogeek.net" appBase="D:\Program Files\Tomcat\test" unpackWARs="true" xmlValidation="false" xmlNamespaceAware="false"> </Host> <Host name="lala.ogeek.net" appBase="webapps" unpackWARs="true" xmlValidation="false" xmlNamespaceAware="false"> </Host> </Engine> <Host name="haha.ogeek.net" appBase="D:\Program Files\Tomcat\test" unpackWARs="true" xmlValidation="false" xmlNamespaceAware="false"> </Host> <Host name="lala.ogeek.net" appBase="webapps" unpackWARs="true" xmlValidation="false" xmlNamespaceAware="false"> </Host> </Engine> 测试在C:\WINDOWS\system32\drivers\etc下的hosts文件中添加如下内容: 按照上面的配置: Engine的dafaultHost:表示访问该tomcat默认进入的主机,注意一定不能是localhost,不然别人通过你的ip访问,就会默认进入tomcat的管理界面. 复制代码 代码如下: <Engine name="Catalina" defaultHost="xixi.ogeek.net"> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> <Host name="xixi.ogeek.net" appBase="webapps" unpackWARs="true" xmlValidation="false" xmlNamespaceAware="false"> <Context path="" docBase="test1" debug="0" reloadable="true" /> </Host> <Host name="haha.ogeek.net" appBase="webapps" unpackWARs="true" xmlValidation="false" xmlNamespaceAware="false"> <Context path="" docBase="test2" debug="0" reloadable="true" /> </Host> <Host name="lala.ogeek.net" appBase="webapps" unpackWARs="true" xmlValidation="false" xmlNamespaceAware="false"> <Context path="" docBase="test3" debug="0" reloadable="true" /> </Host> |
请发表评论