Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ColdFusion 10 Developer, Tomcat 7.0.64, and multiple websites

I recently switched to Mac, and am running El Cap. I have installed ColdFusion 10 developer edition, with internal web server, which is currently Tomcat 7.0.64. I have installed all updates to the ColdFusion server. The CF Administrator on locahost works fine, and I set up port forwarding so that calls in the browser (port 80) are forwarded to the default CF/Tomcat configured port of 8500. This is all working fine.

The way I've worked in windows was pretty straightforward. If I had a website www.example.com, I would set up a local name in HOSTS called www-example-com, and create that host in IIS. This naming convention has been followed for over 30 websites, and has worked well, and I wish to duplicate it with my local CF/Tomcat configuration.

I am editing the file /Applications/ColdFusion10/cfusion/runtime/conf/server.xml, and thought that simply adding another <Host>block would do the trick. Instead I get an error when I try to start ColdFusion up. Without my added block, it works fine. I have provided my current server.xml file below, with my added block. The error I see during startup is:

WARNING: Catalina.start using /Applications/ColdFusion10/cfusion/runtime/conf/server.xml org.xml.sax.SAXParseException: Element type "Valve" must be followed by either attribute specifications, ">" or "/>".

I also understand that editing server.xml directly is not recommended, and in fact it would be nice to have each site's/host's XML file for their Tomcat configuration exist somewhere in their individual directory structure.

My planned directory structure for each site is:

 /Sites/www-example-com
 /Sites/www-example-com/files/private (not web accessible; subdirectories for various private files the site may use, including perhaps tomcat xml config files, etc)
 /Sites/www-example-com/files/public (virtual directory, mapped to appear directly under web root)
 /Sites/www-example-com/www (the root web application directory)

But to avoid possible permissions issues, I placed my first web application under the directory that appears in my added host below.

So what do I need to do to get the configuration I'm looking for? Or am I editing the wrong file(s) altogether, considering tomcat is bundled with CF? (I don't think that matters, since it's still using the same server.xml file and I don't think they've screwed up Tomcat in any way.)

<?xml version="1.0" encoding="UTF-8"?>
<Server port="8007" shutdown="SHUTDOWN">
   <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
   <Listener className="org.apache.catalina.core.JasperListener" />
   <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
   <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
   <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">
      <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" maxThreads="150" minSpareThreads="4" />
      <Connector executor="tomcatThreadPool" maxThreads="50" port="8500" protocol="org.apache.coyote.http11.Http11Protocol" connectionTimeout="20000" redirectPort="8445" />
      <Connector port="8012" protocol="AJP/1.3" redirectPort="8445" tomcatAuthentication="false" />
      <Engine name="Catalina" defaultHost="localhost" jvmRoute="cfusion">
         <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="false">
            <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" resolveHosts="false" />
         </Host>
         <!-- START: the block i tried to add -->
         <Host name="www-example-com" appBase="/Applications/ColdFusion10/cfusion/www-example-com/www" unpackWARs="false" autoDeploy="false">
            <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" resolveHosts="false" />
         </Host>
         <!-- END: the block i tried to add -->
      </Engine>
   </Service>
</Server>
like image 465
Franc Amour Avatar asked Dec 18 '15 12:12

Franc Amour


1 Answers

I ended up installing Lucee and Tomcat as a bundle, and then found information on how to configure tomcat for multiple hosts. the answer (in addition to making sure Mac's native apache and tomcat were connected) was for each entry to appear as follows (note no VALVE entry - not permitted or needed):

<Host name="www-demo-dev"  appBase="webapps" unpackWARs="true" autoDeploy="true">
    <Context path="" docBase="/Users/me/sites/www-demo-dev/www" />
    <Alias>www-demoalias-dev.10.10.10.10.xip.io</Alias>
</Host>     

There's a lot that goes into getting Mac native apache + tomcat + lucee installed!

like image 150
Franc Amour Avatar answered Oct 03 '22 04:10

Franc Amour