Apache2.2 + Tomcat5.5 가상호스트 분리
아파치 서버와 톰캣이 연동이 되었다는 전제하에.
우선, 호스트를 2개로 분리를 하겠습니다.
호스트를 분리한다는 말은 같은 ip로 서로 다른 도메인을 사용하겠다는 의미입니다.
예를 들어 192.168.xx.xxx 의 ip로 http://www.baver.com http://www.gahoo.com 로 접속하겠다는 의미(?)죠-_-
일단, serverl.xml쪽에 host를 두개 추가해줍니다.
<Host name="http://www.baver.com" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="C:/workspace/baver" debug="0" reloadable="true" workDir = "C:/workspace/baver/work"/>
</Host>
<Host name="http://www.gahoo.com" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="C:/workspace/gahoo debug="0" reloadable="true" workDir = "C:/workspace/gahoo/work"/>
</Host>
그리고 나서 아파치 서버의 httpd-vhosts.conf파일에 virtual host를 추가해줍니다.
<VirtualHost *:80>
DocumentRoot "C:/workspace/baver"
ServerName http://www.baver.com
<Directory "C:/workspace/baver">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
DirectoryIndex index.jsp
</Directory>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} \.(htm|html|xhtml|js|css|jpg|gif|png|swf)$
RewriteRule (.*) - [L]
RewriteRule (.*) ajp://localhost:8009$1 [P]
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/workspace/gahoo"
ServerName http://www.gahoo.com
<Directory "C:/workspace/gahoo">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
DirectoryIndex index.jsp
</Directory>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} \.(htm|html|xhtml|js|css|jpg|gif|png|swf)$
RewriteRule (.*) - [L]
RewriteRule (.*) ajp://localhost:8009$1 [P]
</VirtualHost>
그 다음으로 아파치,톰캣 서버를 내렸다가 다시 키신다음에
C:\Windows\System32\drivers\etc 밑에 hosts파일을 연 다음에
각각의 호스트를 추가해줍니다.