Now that our ACME stack has been installed, let's setup some isolated development areas. To do this, we need to create one or more Virtual Hosts in Apache and setup some local domains.
Apache Virtual Hosts
In part 1, we talked about how Apache sets up the localhost domain pointed to files in /var/www/. This is why http://127.0.0.1/ displays It works! (index.html) when you first visited it and why it should display the current date and time (index.cfm) when you go there now.
Rather than run all of your projects under the same root folder and under the localhost domain, it's often a good idea to create a local domain and separate root folder for each project.
http://dev.acme.localhost
Rather than place project files under /var/www/, I often place them under my home directory or in a folder on another disk or partition.
1. Create a new root web directory.
I'm going to create a new directory at the system's root level. This will contain files for all of my projects. You'll have to use sudo to create the folder as the root user.
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org amoreno@amoreno-desktop:~$ sudo mkdir /webroot [sudo] password for amoreno: amoreno@amoreno-desktop:/$ amoreno@amoreno-desktop:/$ ls -l drwxr-xr-x 2 root root 4096 2008-06-24 23:22 webroot1amoreno@amoreno-desktop:~$ sudo mkdir /webroot 2[sudo] password for amoreno: 3amoreno@amoreno-desktop:/$ 4amoreno@amoreno-desktop:/$ ls -l 5drwxr-xr-x 2 root root 4096 2008-06-24 23:22 webroot
Now we need to change the owner of the folder to that of your user account.
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org amoreno@amoreno-desktop:/$sudo chown amoreno.amoreno webroot amoreno@amoreno-desktop:/$ ls -l drwxr-xr-x 4 amoreno amoreno 4096 2008-06-24 23:22 webroot1amoreno@amoreno-desktop:/$sudo chown amoreno.amoreno webroot 2amoreno@amoreno-desktop:/$ ls -l 3drwxr-xr-x 4 amoreno amoreno 4096 2008-06-24 23:22 webroot
Now we can enter this folder under your normal user account and create files and folders without having to use sudo. Let's create a folder for an ACME website:
Create a default page:
2. Create a new Virtual Host entry.
Now we need to let Apache know how to find the files for the ACME website. For that, we need to go to the Apache folder.
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org amoreno@amoreno-desktop:/etc/apache2/sites-available$ sudo gedit acme [sudo] password for amoreno:1amoreno@amoreno-desktop:/etc/apache2/sites-available$ sudo gedit acme 2[sudo] password for amoreno:
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org NameVirtualHost * <VirtualHost *> ServerAdmin webmaster@localhost
DocumentRoot /var/www/ <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory>
CustomLog /var/log/apache2/access.log combined ServerSignature On
Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory>
</VirtualHost>1NameVirtualHost * 2<VirtualHost *> 3 ServerAdmin webmaster@localhost 4 5 DocumentRoot /var/www/ 6<Directory /> 7 Options FollowSymLinks 8 AllowOverride None 9</Directory> 10<Directory /var/www/> 11 Options Indexes FollowSymLinks MultiViews 12 AllowOverride None 13 Order allow,deny 14 allow from all 15</Directory> 16 17 ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ 18<Directory "/usr/lib/cgi-bin"> 19 AllowOverride None 20 Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch 21 Order allow,deny 22 Allow from all 23</Directory> 24 25 ErrorLog /var/log/apache2/error.log 26 27 # Possible values include: debug, info, notice, warn, error, crit, 28 # alert, emerg. 29 LogLevel warn 30 31 CustomLog /var/log/apache2/access.log combined 32 ServerSignature On 33 34 Alias /doc/ "/usr/share/doc/" 35<Directory "/usr/share/doc/"> 36 Options Indexes MultiViews FollowSymLinks 37 AllowOverride None 38 Order deny,allow 39 Deny from all 40 Allow from 127.0.0.0/255.0.0.0 ::1/128 41</Directory> 42 43</VirtualHost>
In the normal distribution of Apache, these settings would be broken up across a few files. The version that is maintained in the Synaptic Package Manager keeps them all in one file, so copying and making changes will be very easy.
0. Remove or comment out the first line (thanks bpickens)
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org <VirtualHost *> ServerName dev.acme.localhost ServerAdmin webmaster@localhost1<VirtualHost *> 2 ServerName dev.acme.localhost 3 ServerAdmin webmaster@localhost
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org DocumentRoot /webroot/iknowkungfoo/acme/1DocumentRoot /webroot/iknowkungfoo/acme/
3. Give Apache permission to access the new folder you created.
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org <Directory /webroot/iknowkungfoo/acme/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory>1<Directory /webroot/iknowkungfoo/acme/> 2 Options Indexes FollowSymLinks MultiViews 3 AllowOverride None 4 Order allow,deny 5 allow from all 6</Directory>
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org ErrorLog /var/log/apache2/acme-error.log1ErrorLog /var/log/apache2/acme-error.log
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org CustomLog /var/log/apache2/acme-access.log combined1CustomLog /var/log/apache2/acme-access.log combined
6. Optional: Create an alias to /CFIDE and other folders.
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org Alias /CFIDE /var/www/CFIDE1Alias /CFIDE /var/www/CFIDE
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org amoreno@amoreno-desktop:/etc/apache2/sites-enabled$1amoreno@amoreno-desktop:/etc/apache2/sites-enabled$
3. Create a new link in sites-enabled.
We just edited the acme file in the sites-available folder. Apache only loads Virtual Host configurations in the sites-enabled folder.
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org amoreno@amoreno-desktop:/etc/apache2/sites-enabled$ sudo /usr/sbin/apache2ctl restart1amoreno@amoreno-desktop:/etc/apache2/sites-enabled$ sudo /usr/sbin/apache2ctl restart
5. Create a new hosts entry.
Every OS has a file that acts like a local Domain Name Server. Open it and add the ServerName you created in the acme file, pointing to 127.0.0.1.
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org amoreno@amoreno-desktop:/etc/apache2/sites-enabled$ sudo gedit /etc/hosts1amoreno@amoreno-desktop:/etc/apache2/sites-enabled$ sudo gedit /etc/hosts
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org 127.0.0.1 localhost 127.0.1.1 amoreno-desktop 127.0.0.1 dev.acme.localhost1127.0.0.1 localhost 2127.0.1.1 amoreno-desktop 3127.0.0.1 dev.acme.localhost
Save and exit gedit.
6. Open the URL in a browser.
You should now be able to enter http://dev.acme.localhost into your browser and see the output from /webroot/iknowkungfoo/acme/index.cfm.
The ACME Guide: 64-bit Ubuntu Edition
{ts '2008-06-25 00:34:28'}
That's it for now
Your 64-bit Ubuntu ColdFusion development environment is now up and running at full steam. If you have any questions or if you'd like to see something else added to this version of The ACME Guide, let me know in the Comments or through my Contact form.
Now that I've got my own ACME setup running, I can get back to the CF + OOP Primer and get some work done on that book I'm supposed to be writing. :)