Install CFMX7.0.2 / Apache2.2 / Centos5.2 / Virtual PC 2007

I’ve just spent the last two days preparing a new development environment on a Virtual PC 2007 VM for the application I’m currently building.
The idea behind this setup is that it mirrors as closely as possible the production environment which is CFMX7.0.2 / Centos 5.2 / Apache 2.2.

It took a lot of abortive attempts to get this right but I finally managed it with the help of the very well written walkthrough by Bill Mitchell which itself refers greatly to another blog post by Steve Erat. Mr Mitchell’s guide is great – it covers several different methods of installing the Apache connector in CFMX7 – he can take all of the credit for this, in fact I copied large sections of his procedure (thanks Mr Mitchell :)).

So I’m going to now give a set of precise instructions on how to set up and configure this dev environment that should work first time. I’m also going to be a bit naughty and provide the wsconfig file for download off my server – this will save some more time.

  1. Begin by installing Centos 5.2 on a virtual machine running in Virtual PC – make sure to use “text mode” for the installation as VPC doesn’t support 24bit graphics and will not display the installer properly.
  2. Once installed, open the ports you need in the Centos firewall
  3. Install LAMP (Apache, PHP & MySQL) using Yum (see this article for details).
  4. Reboot the server and check that everything works properly so far. Once you’re sure it is then it is a good time to enable undo disks in VPC as the next phase of the install can go wrong and if it does you can just revert back to this safe position and try again. To enable undo disks:
    1. shut down the virtual machine
    2. in the VPC console open the VM’s settings
    3. select undo disks (6th item) and enable it
    4. restart the VM
  5. Download the coldfusion-702-lin.bin installer from the Adobe download site – on the main Coldfusion download page you will need to click the "related downloads" link to find the correct download
  6. Disable Selinux (find out how here)
  7. Install libXp
    yum install libXp
  8. Add a coldfusion runtime user
    adduser username
  9. Rename the binary installer
    [root@machine]# cp coldfusion-702-lin.bin coldfusion-702-lin.bin.backup 
  10. Use the following string replace command on the binary to comment out a line that causes problems
    [root@machine]# cat coldfusion-702-lin.bin.backup | sed "s/export LD_ASSUME/#xport LD_ASSUME/" > coldfusion-702-linux.bin 
  11. Make the modified binary executable
    [root@machine]# chmod 755 coldfusion-702-lin.bin 
  12. Execute the installer and select the “Built-In Webserver” option (don’t worry this will be replace with Apache later) IMPORTANT – DON’T LAUNCH THE COLDFUISON SERVER YET – if you do then you’ll have to start all over again.
  13. Open the /opt/coldfusionmx7/runtime/servers/coldfusion/SERVER-INF/jrun.xml file and
    1. Find the entry labeled ProxyService
    2. Add <attribute name=”deactivated”>false</attribute> (changed from true)
    3. Find the entry labeled WebService
    4. Add <attribute name="deactivated">true</attribute> (changed from false)
    5. Find the entry cacheRealPath
    6. Add <attribute name="cacheRealPath">true</attribute> (changed from false)
    7. Save the file
  14. In /opt/coldfusionmx7/runtime/lib/ create a directory called ‘wsconfig’
  15. In /opt/coldfusionmx7/runtime/lib/wsconfig create a driectory called ’1′ (one)
  16. In /opt/coldfusionmx7/runtime/lib/wsconfig create a file called and populate it with:
    #JRun Web Server Configuration File
    # edited by bill 10.31 Thur May 24
    1 .srv=localhost,"coldfusion"

    and save the file

  17. In /opt/coldfusionmx7/runtime/lib/wsconfig/1 create a file called and populate it with:
    proxyservers= The 51011 is for ColdFusion MX 7:
  18. Download this file and place it into the /opt/coldfusionmx7/runtime/lib/wsconfig/1 directory
  19. Change ownership of the wsconfig directory and its contents to the coldfusion user:
    chown -R <coldfusion user> /opt/coldfusionmx7/runtime/lib/wsconfig

    for example, I created a user named ‘coldfusion’ so I entered:

    chown -R coldfusion /opt/coldfusionmx7/runtime/lib/wsconfig

    (when you manually create this folder / file structure everything will be owned by the root user. This will cause problems when Apache attempts to connect to coldfusion – hence the above step)

  20. Edit the httpd config file:
    vi /etc/httpd/conf/httpd.conf

    and find the line containing DirectoryIndex. Add index.cfm to the list of default file names so it should now look something like this:

    DirectoryIndex index.html index.html.var index.cfm

    and then append the following section to the end of the file and re-save it:

    # JRun Settings
    LoadModule jrun_module /opt/coldfusionmx7/runtime/lib/wsconfig/1/
    JRunConfig Verbose false
    JRunConfig Apialloc false
    JRunConfig Ssl false
    JRunConfig Ignoresuffixmap false
    JRunConfig Serverstore /opt/coldfusionmx7/runtime/lib/wsconfig/1/
    JRunConfig Bootstrap
    #JRunConfig Errorurl 
    AddHandler jrun-handler .cfm .cfml .cfc .jsp .jws .cfr .cfswf
  21. Create a symlink to the CFIDE folder in the document root:
    cd /var/www/html
    ln -s /opt/coldfusionmx7/wwwroot/CFIDE
  22. Restart the apache server
    [root@machine ~]# service httpd restart 
  23. Start the Coldfusion server
    [root@machine ~]# service coldfusionmx7 start 
  24. Test everything works properly by putting an index.cfm containing some CFML scripting (eg <cfdump var=”#CGI#”>) into the apache web root and type:

    You should see the CGI dump. Then test the coldfusion administrator works


    where centos-VM is either a domain that you’ve set up for your new VM or its IP address on your LAN

  25. Now you should have a fully working virtual Centos server with CFML (& PHP) support. Don’t forget to install the MySQL connector J Driver too – I already blogged that one here

    Finally you really should should close the VM saving the changes. Before re-launching the VM I would recommend that you copy the VM folder to an archive location – you never know when you might need a freshly installed VM with this environment in the future. Leaving undo disks enabled in Virtual PC is a good idea if you can afford the extra disk space required – if you do break your dev environment in the future and can’t fix it but don’t want to restore the initial image then leaving undo disks enabled will allow you to roll back to the last time you saved your changes. Just remember to save your changes regularly.

    Good luck with it!

CFML Upload file checklist

I always forget how to build upload forms in CFML so here’s a little checklist to remind myself (and anyone else who is interested)

  1. use an HTML form with the following attributes:
    • method=”post”
    • enctype=”multipart/form-data”
    •             <cfform action="index.cfm" enctype="multipart/form-data" method="post">
                      <cfinput type="file" name="inputfile">
                      <cfinput type="submit" name="upload" value="Upload file">
  2. Use a <cffile action=”upload”> tag something along the lines of…
            <cffile  action="upload" 
            <cfcatch type="any">There was an error uploading the file</cfcatch>
  3. use the CFFILE scope to access the structure containing all information about the upload. Here is a sample listing:
    attemptedserverfile	bookmark.htm
    clientdirectory	[empty string]
    clientfile		bookmark.htm
    clientfileext		htm
    clientfilename		bookmark
    contentsubtype		html
    contenttype		text
    datelastaccessed	{ts '2009-06-03 08:52:40'}
    fileexisted		NO
    filesize		10599
    filewasappended	NO
    filewasoverwritten	NO
    filewasrenamed		NO
    filewassaved		YES
    oldfilesize		0
    serverdirectory	/home/myAccount/myaccount/WORK/uploadtest
    serverfile		bookmark.htm
    serverfileext		htm
    serverfilename		bookmark
    timecreated		{ts '2009-06-03 08:52:40'}
    timelastmodified	{ts '2009-06-03 08:52:40'}

Access files from another linux partition using “mount”

I had to copy an installer file over to my new Ubuntu installation from a previouly installed and abandoned Debian Etch install on a different partition.

1. list all partitions of each device

sudo sfdisk -l

Device Boot Start End #cyls #blocks Id System
/dev/sda1 * 0+ 12159 12160- 97675168+ 83 Linux
end: (c,h,s) expected (1023,254,63) found (895,254,63)
/dev/sda2 12160 12767 608 4883760 5 Extended
start: (c,h,s) expected (1023,254,63) found (896,0,1)
end: (c,h,s) expected (1023,254,63) found (479,254,63)
/dev/sda3 12768 24775 12008 96454260 83 Linux
/dev/sda4 24776 25383 608 4883760 82 Linux swap / Solaris
/dev/sda5 12160+ 12767 608- 4883728+ 82 Linux swap / Solaris

from this that I determined that the old partition is called ‘sda1′

2. create a mountpoint called ‘debian’

cd /mnt

sudo mkdir debian

3. mount the partition

sudo mount /dev/sda1 /mnt/debian

4. copy the installer file over from the old partiton to the new

sudo cp /mnt/debian/usr/src/coldfusion8-lin.bin /usr/src

et voila, the 380MB installer is copied over in just a few seconds as opposed to the ten or fifteen minutes that it would take to download it afresh from Adobe.

MSAccess databases on Coldfusion Hosting

Until now I’ve ignored the 10000 MSAccess databases that my Hosting provider “Exabytes” allows me to use because they also gave me 10 MySQL ones to play with. Those have all been used now by the various sites that I have running and now I want to build another database driven site but don’t want to have to pay $25 for an additional MySQL database….

…the solution, of course use one of the MSaccess ones.

This is how I did it… Continue reading

Unzip Joomla! installation files right on your remote ColdFusion server

Having played around a little bit with the Joomla! online demo I got quite interested in it, thinking that I could save myself a lot of time with it. After all, building a content-management system from scratch can take a long time even when the site is quite simple.

Joomla! appears to be a very well thought out open-source solution and I have a couple of clients at the moment who will be benefitting from it I reckon.

I unpacked the zip on my local machine and it extracted over 1700 separate files! Needless to say, uploading those files via FTP took hours, event though the size of the original joomla zip file that I downloaded was less than 3MB. I left it overnight and came back to find that this morning it had finished but with several errors. Not wanting to go through the whole process again I decided to upload the original zip file to my coldfusion server and unpack it there.

If you have ColdFusion hosting that also supports PHP and MySQL and would like to use Joomla then maybe you could benefit from my experience.

This is how I did it: Continue reading