1、Tomcat
打开conf/server.xml配置文件,定位到Host节点,添加项目应用
<Context path="/应用ID" docBase="应用所在目录" debug="0" reloadable="true" crossContext="true"/>
设置reloadable="true"可以让应用更新class文件后tomcat自动reload而不用手动重启
如果要更改端口号,定位到Connector节点,设置port属性即可,tomcat默认的端口号是8080
2、Apache
打开配置文件conf/httpd.conf,定位到LoadModule配置代码块,去掉以proxy开头的配置项注释以启用代理
定位到文件末尾,添加项目应用代理
ProxyPass /example http://localhost:8080/example ProxyPassReverse /example http://localhost:8080/example
3、多域名配置
打开配置文件conf/httpd.conf,定位到“Virtual hosts”配置项,把Include的注释去掉
打开配置文件conf/extra/httpd-vhosts.conf,定位到文件末端,把默认的配置示例删除,添加你的域名与项目应用绑定
<VirtualHost *:80> #设立管理员 ServerAdmin webmaster@farseersoft.com #网站根目录 DocumentRoot D:/webappsroot/fsrweb #绑定的域名 ServerName www.farseersoft.com #网站的别域名 ServerAlias farseersoft.com #以下是出错和其他记录文件 ErrorLog logs/farseersoft.com-error_log CustomLog logs/farseersoft.com-access_log common #设置目录权限 <Directory "D:/webappsroot/fsr"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all Order deny,allow deny from all </Directory> </VirtualHost>
重启tomcat和apache即可生效。