Webhosting Blog

Enable tomcat support for a temporary URL


It is possible to enable temporary URL for tomcat enabled site.

If you want to enable tomcat for temporary/testing URL then refer below steps :

1) Login to the server as root

2) Open the server.xml file.

[ root@server~]# vi /usr/local/jakarata/tomcat/conf/server.xml

3) Add the following code to virtual host entry below the Alias tag.

<Host name="test.com" appBase="/usr/local/apache/htdocs">
 <Alias>www.test.com</Alias>
---->> Add the following code
 <Listener className="org.apache.catalina.startup.UserConfig"
     directoryName="public_html" homeBase="/home"
     userClass="org.apache.catalina.startup.HomesUserDatabase"/>
---->>
     docBase="/usr/local/apache/htdocs" debug="1"/>
 <Context path="/manager" debug="0" privileged="true"
    docBase="/usr/local/jakarta/tomcat/server/webapps/manager">
 </Context>
 </Host>

Save and quit.

4) Now open the apache configuration file and locate the entry for the respective domain name. Add the respective code depending on apache version to the file

[root@server~]# vi /etc/httpd/conf/httpd.conf

The  configuration will be somewhat similar as follows:

<VirtualHost serversIP:80>

ServerName test.com

DocumentRoot /usr/local/apache/htdocs

ServerAdmin test@test.com

<IfModule mod_suphp.c>

suPHP_UserGroup nobody nobody

</IfModule >

——->> Considering apache version is 1 insert the following line.

Include “/usr/local/apache/conf/userdata/std/1/nobody/hostname/*.conf”

——–>>

</VirtualHost>

Similar code to be added for the https virtualhost entry.

<VirtualHost serversIP:443>

ServerName test.com

DocumentRoot /usr/local/apache/htdocs

ServerAdmin test@test.com

<IfModule mod_suphp.c>

suPHP_UserGroup nobody nobody

</IfModule >

Include “/usr/local/apache/conf/userdata/std/1/nobody/hostname/*.conf”

</VirtualHost>

save and quit.

5) Create the directory /usr/local/apache/conf/userdata/std/1/nobody/test.com/

[root@server~]#  mkdir -p /usr/local/apache/conf/userdata/std/1/nobody/test.com/

6) Create a file  cp_jkmount.conf in the above path and insert following code in it.

[root@server~]# vi /usr/local/apache/conf/userdata/std/1/nobody/test.com/cp_jkmount.conf

<IfModule mod_jk.c>
JkMount /*.jsp ajp13
JkMount /servlet/* ajp13
JkMount /servlets/* ajp13
JkMount /*.* ajp13
JkMount /* ajp13
JkMount /*.jspx ajp13
</IfModule>

Save and Quit.

7) Now restart the tomcat and apache service.

8 ) Now Try Accessing http://test.com/~username

Advertisements

2 responses

  1. Pingback: Setup WAMP Apache to use virtual hosts instead of aliases? (also mod_rewrite)? | Uncategorized | Information about Social Bookmarking Software, Social Bookmarking Tool

  2. Pingback: Apache: disable directory listing « Php Bugs

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s