Reputation: 3205
I am using Linux 12.04 Precise. I just have sudo rights on my machine. I have created a jsp website and tried to create virtual hosts on my machine so that the website url look distinguished like :
www.myapp.com
rather than
127.0.0.1/myapp/
So, after going through many articles on the internet. Like
I have created an entry in server.xml like below for my virtual host
<Engine name="Catalina" defaultHost="localhost">
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host>
<Host name="www.myapp.com" appBase="libapps" unpackWARs="true"
autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
</Host>
</Engine>
For this, as mentioned in the tutorial, I have created a directory in $CATALINA_HOME named libapps and placed my application war file inside. When i look into the host-manager app of tomcat6, it is showing my virtual host but it is not working on starting. Before this, i have restarted tomcat6 on changing server.xml.
What else can i do to make my application functional ??
Upvotes: 0
Views: 2793
Reputation: 3205
Done with simple steps after a long follow through of internet tutorials :)
Step 1 : Add an entry in your server.xml
<Host name="www.your-domain.com" appBase="libapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host>
Step 2 : Create directories in your $CATALINA_HOME for the appbase
sudo mkdir /var/lib/tomcat6/libapps
Create following directories for virtual-host configuration
sudo mkdir /var/lib/tomcat6/conf/Catalina/www.your-domain.com
Copy following files to this directory
host-manager.xml
manager.xml
ROOT.xml
from
/var/lib/tomcat6/conf/Catalina/localhost
directory
Step 3 : Add an entry in /etc/hosts file
XX.XX.XX.XX www.your-domain.com
Step 4 : After this just restart your tomcat using following command
sudo service tomcat6 restart
Step 5 : Now, you can access your new virtual-host by typing following url in your browser
www.your-domain.com:8080
Step 6 : Just access manager app from this host and deploy your war file. :)
Step 7 : Now, if you want to remove ip address from the url and use a good looking url like
www.your-domain.com
Then, you have to make an entry in
/etc/apache2/httpd.conf
like below:
ProxyPass / http://www.your-domain.com:8080/app-name/
ProxyPassReverse / http://www.your-domain.com:8080/app-name/
Step 8 : Now, you can access your application from
www.your-domain.com
Upvotes: 2