Wednesday 4 September 2013

How to configure Railo – Tomcat – Apache on MAC Lion Mountain 10.8

Last week I updated my operating system from Snow Leopard  to Lion Mountain 10.8, system has upgraded itself.

Only two problems I faced:

1) Little Snitch got removed (V 2.2), I had to buy Licence for upgrade of version 3.02 – Lion cost me more :(

2) I had ColdFusion 9.01, which stopped working as Lion upgrade had reinstalled Apache removed old httpd.conf and httpd-vhost.conf files (actually renamed them as httpd.conf~previous.

I tried to move virtual sites from old to new but it didn’t work.

Web Sharing option got removed from System Preference - To get it back I found this post which provides a tool to get it in Sys Pref under Other:

Explanation, good article to read: Restore Web Sharing in Mountain Lion

Get the tool from here: WEB SHARING IN OS X MOUNTAIN LION

I made few changes to Apache config files, by default it uses web server document folder here:

/Library/WebServer/Documents

I have changed this and few other settings in httpd.conf (/private/etc/apache2/)

1) Find ServerAdmin and change email address to yours one (around line no 153)

2) Find ServerName and change it to cfdev also add following in hosts file (/private/etc/)

127.0.0.1 cfdev  (now you can get to your webserver by localhoost/ cfdev/ 127.0.0.1)

Make sure you uncomment this line (at line no 481) Include /private/etc/apache2/extra/httpd-vhosts.conf

3) create a folder sites or whatever name you waant to give at root level

4) Find DocumentRoot (line no 169) and change it to “/sites”

5) Find < Directory and change it with “/sites”

6) Open file httpd-vhost.conf from /private/etc/apache2/extra/

7) Uncomment NameVirtualHost *:80 (Line no 19)

8) Add following virtual host (default) site


DocumentRoot “/sites”
ServerName cfdev
DirectoryIndex index.html


9) Add / Create index.html in /sites folder as a place holder

10) sudo apachectl restart (to pick-up the changes

now open browser and browse http://cfdev or http://localhost and you should see your default web page

Railo Installation:

Download your railo installer from here

Scroll down and pick MacOS installer infront of Railo Server with Tomcat 7 title

Open it up and follow the default steps:

It will normally Install under this location and picks port 8080 – /Library/Railo/tomcat/

now if you browse http://localhost:8080/ you should see the tomcat page

1) Open web.xml from tomcat/conf folder

Add following at around line 422 (This will help if you use CFWheels frame-work


GlobalCFMLServlet
/rewrite.cfm/*


2) Open server.xml from tomcat/conf

3) go to line no 90 and un comment following:



This will help us to use apache server on port 80 to create virtual sites.

at around line 123 you will see default website for this Tomcat server

create a folder under /sites folder – which will be your first local site say – firstSite

inside the folder create index.cfm

now create a virtual site in server.xml like this: (above
)
unpackWARs=”true” autoDeploy=”true”
xmlValidation=”false” xmlNamespaceAware=”false”>



save the file and restart the server (Tomcat):

4) open terminal window and go to /Library/Railo/tomcat/bin

run following command: sudo sh shutdown.sh (to shutdown the server)

Now run this command to start it: sudo sh startup.sh

5) add following in hosts file: 127.0.0.1 dev.firstsite.com

now browse http://dev.firstsite.com:8080 and you will see your first site index.cfm running

6) open httpd.conf from /private/etc/apache2/

add following (Thanks to Anuj Gakhar this post)


Allow from 127.0.0.1


ProxyPreserveHost On
ProxyPassMatch ^/flex2gateway/(.*)$ ajp://localhost:8009/flex2gateway/$
ProxyPassMatch ^/messagebroker/(.*)$ ajp://localhost:8009/messagebroker/$1
ProxyPassMatch ^/(.+\.cf[cm])(/.*)?$ ajp://localhost:8009/$1$2

now open httpd-vhosts.conf from /apache2/extra/ folder and add virtual site (key to this set up is you need to add virtual site pointing to the same folder with same url under both servers)


DocumentRoot /sites/firstSite
DirectoryIndex index.cfm

AllowOverride All
Order allow,deny
Allow from all
Options +Indexes

ErrorLog firstsite.error.log
LogLevel warn


restart your apache server and

browse http://dev.firstsite.com  and you should see your site running on port 80

No comments: