Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Tip

Start with a Tomcat bundle of your choice, for a selection of bundles see list of preconfigured Magnolia bundles. If you want to test multisite scenarios, choose an EE pro bundle (such as magnolia-enterprise-pro-demo-bundle).

If want to get rid of the demo modules to start with a virginal vanilla multisite module - remove the appropriate modules before you start the bundle for the first time. (On magnolia-enterprise-pro-demo-bundle delete the modules starting with magnolia-travel* from the folder magnolia-enterprise-x.y.z/apache-tomcat-8.5.5/webapps/magnoliaAuthor/WEB-INF/lib).

Before following the steps explained below, start the bundle as usual, to make sure both webapps magnoliaAuthor and magnoliaPublic are installed and work properly.

...


Table of Contents

Domains and /etc/hosts

This is an overview of the the multisite setup:

...


author instancepublic instance
comicsauthor.best-comics.netwww.best-comics.net
vinylauthor.best-comics.netwww.best-vinyl.net

...

I guess there are different possible solutions to serve a Magnolia instance from Tomcat root context. Here comes one:

...

Use the <Context> directive which allows to define the path of a webapp.

Code Pro
<Context path="" docBase="magnoliaAuthor" />

The empty string ("") as value of the path attribute ensures to serve the webapp magnoliaAuthor from the root context.


Expand
titleClick here to expand to see the complete server.xml
Code Pro
languagexml
titleserver.xml
linenumberstrue
<?xml version="1.0" encoding="UTF-8"?>
<Server 
languagexml
titleserver.xml
linenumberstrue
<?xml version="1.0" encoding="UTF-8"?>
<Server port="8005" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />


  <GlobalNamingResources>
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>


  <Service name="Catalina">

    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />


	<Connector port="8009" enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />

    <Engine name="Catalina" defaultHost="localhost">

      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>

      <Host name="localhost"  appBase="webapps" unpackWARs="true" autoDeploy="true">
		<!-- serverserve authormagnoliaAuthor from root -->  
		<Context path="" docBase="magnoliaAuthor" />
    
	    <Valve className="org.apache.catalina.valves.AccessLogValve" 
			directory="logs" 
			prefix="localhost_access_log" 
			suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
      </Host>
	  
    </Engine>
	
  </Service>
  
</Server>

See line 37ensures the context magnoliaAuthor is served from root. Note that Tomcat can only serve : Added <Context> directive.

Tomcat can serve only one webapp from root within the same

...

host and within the same service.

It works.

However, since now we have only one context served from root. 

...

  • Lines 3-4: author.best-comics.net redirects to localhost on port 8080
    => webapp magnoliaAuthorauthor instance
  • Lines 9-10, 15-16: www.best-comics.net and www.best-vinyl.net are redirected to localhost on port 8081 => 
    => webapp magnoliaPublicpublic instance
  • The lines configuring the log files of the virtual hosts have been removed to keep this configuration excerpt small.

...

  • Create the folder webapps2.
  • Move the webapp magnoliaPublic to webapps2.
  • You may want delete the webapp ROOT, you won't be able to access it anymore.

...


server.xml

This is the server.xml:

...

Advanced Tables - Table Plus
heading0
multiplefalse
enableHeadingAttributesfalse
enableSortingfalse
classm5-configuration-tree
enableHighlightingfalse
Node nameValue

Mgnl f
server

 

Mgnl f
activation

 

Mgnl f
subscribers

 

Mgnl n
magnoliaPublic8080

 

Mgnl n
subscriptions

 

Mgnl p
URL

http://localhost:8081

 Note that the activation is using the HTTP connector.

...

multiplefalse
enableHeadingAttributesfalse
enableSortingfalse
classm5-configuration-tree
enableHighlightingfalse
Node nameValue

Mgnl f
server


Mgnl f
activation


Mgnl f
subscribers


Mgnl n
magnoliaPublic8080


Mgnl n
subscriptions


Mgnl p
URL

http://localhost:8081

 Note that the activation is using the HTTP connector.

URLs of the final setup

If you have all done correctly - you can access the Magnolia instance by the following URLs

author instance
author.best-comics.netvia Apache and AJP connector
author.best-comics.net:8080via Tomcat and HTTP connector
localhost:8080
public instance
www.best-comics.netvia Apache and AJP connector
www.best-comics.net:8081via Tomcat and HTTP connector
www.best-vinyl.netvia Apache and AJP connector
www.best-vinyl.net:8081via Tomcat and HTTP connector
localhost:8081