Our Drupal Site Backed Up to a Laptop

Putting MakeKC.org on a Laptop

I have been spending time lately learning more about Drupal. The more I learn, the more I’m impressed with the system so I decided to write this up and post it to my blog.

I’ve wanted to have a local copy of our MakeKC live website on my home machine for testing and backup but I was having trouble getting the database installed. The phpMySql program wouldn’t let the large database dmp file load. The solution was actually simple but requires a command line keyin in the form:

mysql -u username -p databasename < backupfilename.sql

or in my case:

mysql -u makekcAcct -p databaseForMakekc < myHostingAcct-databaseForMakekc-4-25-2011.dmp 

I copied all of the files from makekc.org’s drupal6 directory down to my local machine. I have Ubuntu with Apache, PHP, and MySql installed. I copied the directory to my computer at:  ~home/www/makekc.local/drupal6 (where ~home is the shortcut notation for my home directory).

I added the a static IP address to the /etc/hosts file    localhost    makekc.local

(I happen to be using other ip addresses and the next in line was at the time).

A Revelation About Website Root Directories

I’m using the versions of Apache, PHP, and MySql offered by Ubuntu’s Synaptic Package Manager. This causes my web site files to be placed off the root directory at /var/www/myVirtualDomains. Up until now I thought each of my local web sites had to go into the /var/www/ directory for special web site purposes. I wondered if pointing to a different web root directory inside my home directory would work. So I added the following to my /etc/apache2/sites-enabled/000-default file:

<VirtualHost makekc.local:80>
   ServerAdmin webmaster@makekc.local
   DocumentRoot /home/someoneknows/www/makekc.local/drupal6
   ServerName makekc.local
   ServerAlias www.makekc.local
   ErrorLog /var/log/apache2/makekc.local-error_log
   CustomLog /var/log/apache2/makekc.local-access_log common

Turns out it that pointing to a web root directory in my login account works there too.

With the website files and the web server configuration in place I restarted the server. Then navigated to the web page using makekc.local. The same homepage from the live website was showing up on my makekc.local site too. But when I tried logging in or going to one of the links in the site they didn’t work.

Enabling Clean URLs

I finally realized that the links to other pages probably weren’t working because Clean URLs are enabled on the live site but my default apache installation didn’t allow my Drupal install to Enable Clean URLs.  I didn’t take the time to learn how to apply the proper configuration at the time for my laptop computer to allow mod_rewrite to work.

It took a while but I finally found the command “sudo a2enmod rewrite“, this sets up apache to allow rewrites to happen. Then I changed the /ect/apache2/sites-enabled/000-default file again to change AllowOveride  None to AllowOverride All as in:

   <Directory />
       Options FollowSymLinks
       AllowOverride All

After restarting Apache again I finally have a working local copy on my computer with the same contents and functionality as our live site.

 About SomeoneKnows 
(c) 2011 Vince Thompson