Setting Up Virtual Hosts on OC4J

Objective

Setup multiple domains using a single IP address.

Requirements

This is a very basic example, it does not take into account using shared applications or event the use of .war or .ear files. This is left as an exercise for the reader.

  • Example Domains: gerardnico.com,
  • Example IP Address: 127.0.0.1

Steps

Create directories under $OC4J_HOME\applications\ for each domain.

    mkdir $OC4J_HOME\applications\gerardnico

Add to the directory a index.html file.

Contents of $OC4J_HOME\applications\gerardnico\index.html:

    <html><head><title>gerardnico.com</title></head>
      <body bgcolor="#FFFFFF">
        <h2>gerardnico.com</h2>
      </body>
    </html> 

Create WEB-INF directories for the domains.

    mkdir $OC4J_HOME\applications\gerardnico\WEB-INF

Each WEB-INF directory should contain a web.xml file.

Contents of $OC4J_HOME\applications\gerardnico\WEB-INF\web.xml

    <web-app>
 
      <display-name>gerardnico.com</display-name>
 
      <description>
        gerardnico.com
      </description>
 
      <welcome-file-list>
        <welcome-file>index.html</welcome-file>
      </welcome-file-list>
 
    </web-app>

Create web-site XML file for each domain.

Contents of $OC4J_HOME\config\gerardnico-web-site.xml:

    <web-site host="127.0.0.1" port="80" display-name="gerardnico" virtual-hosts="gerardnico.com">
 
      <!-- The default web-app for this site, bound to the root -->
      <default-web-app application="default" name="gerardnico" />
 
      <access-log path="../log/gerardnico-web-access.log" />
 
    </web-site> 

Edit $OC4J_HOME\config\application.xml. Add the following lines:

     <web-module id="gerardnico" path="../../home/applications/gerardnico" />

Edit $OC4J_HOME\config\server.xml. Add the following lines:

    <web-site path="./gerardnico-web-site.xml" />

Restart OC4J and test.

Reference

  • Bookmark "Setting Up Virtual Hosts on OC4J" at del.icio.us
  • Bookmark "Setting Up Virtual Hosts on OC4J" at Digg
  • Bookmark "Setting Up Virtual Hosts on OC4J" at Ask
  • Bookmark "Setting Up Virtual Hosts on OC4J" at Google
  • Bookmark "Setting Up Virtual Hosts on OC4J" at StumbleUpon
  • Bookmark "Setting Up Virtual Hosts on OC4J" at Technorati
  • Bookmark "Setting Up Virtual Hosts on OC4J" at Live Bookmarks
  • Bookmark "Setting Up Virtual Hosts on OC4J" at Yahoo! Myweb
  • Bookmark "Setting Up Virtual Hosts on OC4J" at Facebook
  • Bookmark "Setting Up Virtual Hosts on OC4J" at Yahoo! Bookmarks
  • Bookmark "Setting Up Virtual Hosts on OC4J" at Twitter
  • Bookmark "Setting Up Virtual Hosts on OC4J" at myAOL
 
web_server/oc4j/oc4j_virtualhost.txt · Last modified: 2009/05/20 13:53 by gerardnico