This page explains how to integrate the Apache httpd, Apache Tomcat and OpenCms 5.0 so that
This configuration has been tested with the following components:
Please note: Make sure that all your server names are correctly configured in your DNS before you continue with this installation. If a server can not be reached with the name(s) used in the configuration files below, the setup will not work.
I will describe the required steps to setup the following scenario:
Provided that you have a basic setup of Apache Tomcat and Apache httpd, you should install OpenCms in the {$TOMCAT_HOME}/webapps/ directory first, without modifiying the default Tomcat configuration.
In order for this setup to work you must install opencms as the ROOT Tomcat servlet context. Read on to learn how to do so.
I will assume that OpenCms is the only web application installed in your Tomcat system. Please make sure that the {$TOMCAT_HOME}/webapps/ is empty before you proceed. You probably have to delete or move the Tomcat default web applications examples/, webdav/, tomcat-docs/ and ROOT/ to empty the directoy. In case you want to keep these example web applications, you must as last remove the ROOT/ application.
Important: Make sure that NO web application named opencms/ is installed in {$TOMCAT_HOME}/webapps/, otherwise this setup will not work.
Now use the standard steps required to install OpenCms as described in the basic installation manual, available e.g. in the org.opencms.welcome module. However, before you deploy the file opencms.war as described in setp 4 of the basic installation manual, you must rename this file to ROOT.war.
Continue with the OpenCms setup as described in the basic installation manual.
In this example I will be installing OpenCms on my opencms.alkacon.com server, so the path to the setup wizard on my machine will be http://opencms.alkacon.com:8080/ocsetup.
The setup wizard should work fine now and you should be able to login into your OpenCms system. You might note that some images do not appear as they should. We will fix that in the next step.
Now open the OpenCms configuration file {$TOMCAT_HOME}/webapps/ROOT/WEB-INF/config/opencms.properties.
Around line 450, locate the following 2 keys:
url_prefix_export=/${WEB_APP_NAME}/export url_prefix_http=/${WEB_APP_NAME}/opencms
Change the values of these 2 keys to:
url_prefix_export=/export url_prefix_http=
This is all that you have to do in the OpenCms configuration.
Please note:After you have made these changes, OpenCms will run correctly until you have also made the changes described below in the Tomcat and Apache configuration.
Locate the file server.xml in the {$TOMCAT_HOME}/conf/ directory. Before making any changes, make a backup copy of this file.
Here is how my server.xml file looks after I have made all required changes to it:
<Server port="8005" shutdown="SHUTDOWN" debug="0"> <Service name="Tomcat-Standalone"> <!-- Define a combined connector for the "public visible" server names --> <Connector className="org.apache.coyote.tomcat4.CoyoteConnector" port="8081" minProcessors="5" maxProcessors="75" proxyName="test.alkacon.com" proxyPort="80" enableLookups="true" redirectPort="8443" acceptCount="100" debug="0" connectionTimeout="20000" useURIValidationHack="false" disableUploadTimeout="true" /> <!-- Define one connector for the "internal" editor server --> <Connector className="org.apache.coyote.tomcat4.CoyoteConnector" port="8082" minProcessors="5" maxProcessors="75" proxyName="opencms.alkacon.com" proxyPort="80" enableLookups="true" redirectPort="8443" acceptCount="100" debug="0" connectionTimeout="20000" useURIValidationHack="false" disableUploadTimeout="true" /> <Engine name="Standalone" defaultHost="localhost" debug="0"> <Host name="localhost" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true"> <!-- You can change "unpackWARs" and "autoDeploy" to false after the installation is finished --> <Logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="localhost_log." suffix=".txt" timestamp="true"/> </Host> </Engine> </Service> </Server>
You should copy and paste this code to your server.xml and change the server names test.alkacon.com and opencms.alkacon.com to your local server names.
In this configuration I use the server test.alkacon.com as Tomcats internal name for both test01.alkacon.com and test02.alkacon.com. This means that for Tomcat, all request.getHostName() calls in a Java class or JSP will return test.alkacon.com. In case you want to distinguish the hostnames between requests, you could also add one inidividual <Connector> node for each host name you have.
This should be all you need to configure Tomcat. Please note that the "standard" standalone connector usually available at port 8080 has been removed, and so is not longer available. Also, all Tomcat options unrelated to OpenCms have been removed. In case you are using other Tomcat web applications that require further settings for in your server.xml , you must merge these with the OpenCms settings decribed above.
Please note: You must first finish the Apache configuration described in the next step to check if Tomcat and OpenCms work correctly.
First, make sure you have the following Apache modules enabled (around line 130 in the Apache httpd.conf).
LoadModule alias_module modules/mod_alias.so LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_http_module modules/mod_proxy_http.so
Now you have to configure the <VirtualHost> entries for your OpenCms installation. In my example system, I add one <VirtualHost> entry for each of my three servers like this:
<VirtualHost *> ServerName opencms.alkacon.com ServerAdmin webmaster@alkacon.com DocumentRoot "C:/Java/Tomcat4_1_8/webapps/ROOT/" ErrorLog logs/error.log # Log only non-redirect requests in "normal" log file SetEnvIf Request_URI "\/opencms\/*" redirect CustomLog logs/localhost-access.log common env=!redirect ProxyPass /opencms/ ! RedirectPermanent /opencms/ http://opencms.alkacon.com/ ProxyPass /resources/ ! ProxyPass /export/ ! ProxyPass / http://127.0.0.1:8082/opencms/ ProxyPassReverse / http://127.0.0.1:8082/opencms/ </VirtualHost> <VirtualHost *> ServerName test01.alkacon.com ServerAdmin webmaster@alkacon.com DocumentRoot "C:/Java/Tomcat4_1_8/webapps/ROOT/" ErrorLog logs/error.log # Log only non-redirect requests in "normal" log file SetEnvIf Request_URI "\/opencms\/*" redirect CustomLog logs/test01-access.log common env=!redirect # Multi domain configuration: All pages in "/release/" are to be served from domain "test02.alkacon.com" ProxyPass /release/ ! RedirectPermanent /release/ http://test02.alkacon.com/release/ ProxyPass /opencms/ ! RedirectPermanent /opencms/ http://test01.alkacon.com/ ProxyPass /resources/ ! ProxyPass /export/ ! ProxyPass / http://127.0.0.1:8081/opencms/ ProxyPassReverse / http://127.0.0.1:8081/opencms/ </VirtualHost> <VirtualHost *> ServerName test02.alkacon.com ServerAdmin webmaster@alkacon.com DocumentRoot "C:/Java/Tomcat4_1_8/webapps/ROOT/" ErrorLog logs/error.log # Log only non-redirect requests in "normal" log file SetEnvIf Request_URI "\/opencms\/*" redirect CustomLog logs/test02-access.log common env=!redirect # Multi domain configuration: All pages in "/alkacon-documentation/" are to be served from domain "test02.alkacon.com" ProxyPass /alkacon-documentation/ ! RedirectPermanent /alkacon-documentation/ http://test01.alkacon.com/alkacon-documentation/ ProxyPass /opencms/ ! RedirectPermanent /opencms/ http://test02.alkacon.com/ ProxyPass /resources/ ! ProxyPass /export/ ! ProxyPass / http://127.0.0.1:8081/opencms/ ProxyPassReverse / http://127.0.0.1:8081/opencms/ </VirtualHost>
Again, you must adjust the names of the server to your environment, and also adjust other variables like the ServerAdmin or the DocumentRoot to match your system.
This should be it! Start Tomcat and Apache and see if you can log in to your OpenCms system.
]]>This page explains how to integrate the Apache httpd, Apache Tomcat and OpenCms 5.0 so that
This configuration has been tested with the following components:
Please note: Make sure that all your server names are correctly configured in your DNS before you continue with this installation. If a server can not be reached with the name(s) used in the configuration files below, the setup will not work.
I will describe the required steps to setup the following scenario:
Provided that you have a basic setup of Apache Tomcat and Apache httpd, you should install OpenCms in the {$TOMCAT_HOME}/webapps/ directory first, without modifiying the default Tomcat configuration.
In order for this setup to work you must install opencms as the ROOT Tomcat servlet context. Read on to learn how to do so.
I will assume that OpenCms is the only web application installed in your Tomcat system. Please make sure that the {$TOMCAT_HOME}/webapps/ is empty before you proceed. You probably have to delete or move the Tomcat default web applications examples/, webdav/, tomcat-docs/ and ROOT/ to empty the directoy. In case you want to keep these example web applications, you must as last remove the ROOT/ application.
Important: Make sure that NO web application named opencms/ is installed in {$TOMCAT_HOME}/webapps/, otherwise this setup will not work.
Now use the standard steps required to install OpenCms as described in the basic installation manual, available e.g. in the org.opencms.welcome module. However, before you deploy the file opencms.war as described in setp 4 of the basic installation manual, you must rename this file to ROOT.war.
Continue with the OpenCms setup as described in the basic installation manual.
In this example I will be installing OpenCms on my opencms.alkacon.com server, so the path to the setup wizard on my machine will be http://opencms.alkacon.com:8080/ocsetup.
The setup wizard should work fine now and you should be able to login into your OpenCms system. You might note that some images do not appear as they should. We will fix that in the next step.
Now open the OpenCms configuration file {$TOMCAT_HOME}/webapps/ROOT/WEB-INF/config/opencms.properties.
Around line 450, locate the following 2 keys:
url_prefix_export=/${WEB_APP_NAME}/export url_prefix_http=/${WEB_APP_NAME}/opencms
Change the values of these 2 keys to:
url_prefix_export=/export url_prefix_http=
This is all that you have to do in the OpenCms configuration.
Please note:After you have made these changes, OpenCms will run correctly until you have also made the changes described below in the Tomcat and Apache configuration.
Locate the file server.xml in the {$TOMCAT_HOME}/conf/ directory. Before making any changes, make a backup copy of this file.
Here is how my server.xml file looks after I have made all required changes to it:
<Server port="8005" shutdown="SHUTDOWN" debug="0"> <Service name="Tomcat-Standalone"> <!-- Define a combined connector for the "public visible" server names --> <Connector className="org.apache.coyote.tomcat4.CoyoteConnector" port="8081" minProcessors="5" maxProcessors="75" proxyName="test.alkacon.com" proxyPort="80" enableLookups="true" redirectPort="8443" acceptCount="100" debug="0" connectionTimeout="20000" useURIValidationHack="false" disableUploadTimeout="true" /> <!-- Define one connector for the "internal" editor server --> <Connector className="org.apache.coyote.tomcat4.CoyoteConnector" port="8082" minProcessors="5" maxProcessors="75" proxyName="opencms.alkacon.com" proxyPort="80" enableLookups="true" redirectPort="8443" acceptCount="100" debug="0" connectionTimeout="20000" useURIValidationHack="false" disableUploadTimeout="true" /> <Engine name="Standalone" defaultHost="localhost" debug="0"> <Host name="localhost" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true"> <!-- You can change "unpackWARs" and "autoDeploy" to false after the installation is finished --> <Logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="localhost_log." suffix=".txt" timestamp="true"/> </Host> </Engine> </Service> </Server>
You should copy and paste this code to your server.xml and change the server names test.alkacon.com and opencms.alkacon.com to your local server names.
In this configuration I use the server test.alkacon.com as Tomcats internal name for both test01.alkacon.com and test02.alkacon.com. This means that for Tomcat, all request.getHostName() calls in a Java class or JSP will return test.alkacon.com. In case you want to distinguish the hostnames between requests, you could also add one inidividual <Connector> node for each host name you have.
This should be all you need to configure Tomcat. Please note that the "standard" standalone connector usually available at port 8080 has been removed, and so is not longer available. Also, all Tomcat options unrelated to OpenCms have been removed. In case you are using other Tomcat web applications that require further settings for in your server.xml , you must merge these with the OpenCms settings decribed above.
Please note: You must first finish the Apache configuration described in the next step to check if Tomcat and OpenCms work correctly.
First, make sure you have the following Apache modules enabled (around line 130 in the Apache httpd.conf).
LoadModule alias_module modules/mod_alias.so LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_http_module modules/mod_proxy_http.so
Now you have to configure the <VirtualHost> entries for your OpenCms installation. In my example system, I add one <VirtualHost> entry for each of my three servers like this:
<VirtualHost *> ServerName opencms.alkacon.com ServerAdmin webmaster@alkacon.com DocumentRoot "C:/Java/Tomcat4_1_8/webapps/ROOT/" ErrorLog logs/error.log # Log only non-redirect requests in "normal" log file SetEnvIf Request_URI "\/opencms\/*" redirect CustomLog logs/localhost-access.log common env=!redirect ProxyPass ${OpenCmsContext}/ ! RedirectPermanent ${OpenCmsContext}/ http://opencms.alkacon.com/ ProxyPass /resources/ ! ProxyPass /export/ ! ProxyPass / http://127.0.0.1:8082${OpenCmsContext}/ ProxyPassReverse / http://127.0.0.1:8082${OpenCmsContext}/ </VirtualHost> <VirtualHost *> ServerName test01.alkacon.com ServerAdmin webmaster@alkacon.com DocumentRoot "C:/Java/Tomcat4_1_8/webapps/ROOT/" ErrorLog logs/error.log # Log only non-redirect requests in "normal" log file SetEnvIf Request_URI "\/opencms\/*" redirect CustomLog logs/test01-access.log common env=!redirect # Multi domain configuration: All pages in "/release/" are to be served from domain "test02.alkacon.com" ProxyPass /release/ ! RedirectPermanent /release/ http://test02.alkacon.com/release/ ProxyPass ${OpenCmsContext}/ ! RedirectPermanent ${OpenCmsContext}/ http://test01.alkacon.com/ ProxyPass /resources/ ! ProxyPass /export/ ! ProxyPass / http://127.0.0.1:8081${OpenCmsContext}/ ProxyPassReverse / http://127.0.0.1:8081${OpenCmsContext}/ </VirtualHost> <VirtualHost *> ServerName test02.alkacon.com ServerAdmin webmaster@alkacon.com DocumentRoot "C:/Java/Tomcat4_1_8/webapps/ROOT/" ErrorLog logs/error.log # Log only non-redirect requests in "normal" log file SetEnvIf Request_URI "\/opencms\/*" redirect CustomLog logs/test02-access.log common env=!redirect # Multi domain configuration: All pages in "/alkacon-documentation/" are to be served from domain "test02.alkacon.com" ProxyPass /alkacon-documentation/ ! RedirectPermanent /alkacon-documentation/ http://test01.alkacon.com/alkacon-documentation/ ProxyPass ${OpenCmsContext}/ ! RedirectPermanent ${OpenCmsContext}/ http://test02.alkacon.com/ ProxyPass /resources/ ! ProxyPass /export/ ! ProxyPass / http://127.0.0.1:8081${OpenCmsContext}/ ProxyPassReverse / http://127.0.0.1:8081${OpenCmsContext}/ </VirtualHost>
Again, you must adjust the names of the server to your environment, and also adjust other variables like the ServerAdmin or the DocumentRoot to match your system.
This should be it! Start Tomcat and Apache and see if you can log in to your OpenCms system.
]]>