Skip to main content

Make a dev copy of a Joomla! site

I look this up all the time, wanted to document it here so I know just where to find it.  With this, I end up with a subdirectory in the production site named dev.  I then make that a separate named virtual host in my apache configuration, and protect the development environment with htpasswd authentication.
Naturally replace all the italics with your environment needs.

NOTE:  Do not do any work in development until you have completed all the steps!

 

 

Copy the production Joomla! database to SQL statements

  • In MySQLAdmin, or your database administration panel of choice
  • Choose the production database
  • Backup Database to a local file, as a file of SQL Statements.  I typically use my local home directory, database name, and add the date, so mine would show:          Path on Server: /home/my_home/database_date
  • Execute the Backup

Copy the directory structure and contents of the production server, via tar.  I typically use my local home directory and website name for the file name.
I have ssh access, so I can do this via the command line, and prefer to use the command line.  Your process may vary based on your ftp/ssh abilities.

  • Log in to the server
  • cd /your_production_directory
  • rm -rf dev (if needed)  Otherwise you end up with cascading dev directories, and waste a bunch of space.
  • tar -cvf /home/my_home/website_name.tar .
    (Note the trailing . there.  This copies all the files/directories from your current directory (production website) to the tar file in your home directory.

Set up the development database.  This will be an exact replica of production, at this point.

  • In MySQLAdmin, or your database administration panel of choice
  •  Drop the dev version of the production database (if needed)
  • Create the new database, production_database_dev
  • populate database by Executing the SQL statements stored in /home/my_home/database_date

Populate the development directory

  • cd /your_production_directory
  • mkdir dev
  • chown apache:apache dev
    (This is necessary if you are not logged in as apache, at least for me...)
  • cd dev
  • tar -xvf /home/my_home/website_name.tar
  • Make sure the directory was created correctly
  • cd /your_production_directory/dev
  • ls -alF  allows you to verify the files/directories look the same as the production directory

Modify the configuration.php in dev to point to the dev database

  • Update configuration.php
  •  chmod 644 configuration.php
  • vi configuration.php
  • change Joomla database name "production_database_dev"
  • chmod 444 configuration.php

Make sure you can see it is dev, using either website_URL/dev or if you have a name setup for dev, use that.

  • Go to website_URL/dev/administrator
  • Global Configuration - Change site name to include Test
  • Content - Home Page Add "Test Site" to the top of the article
  • Go to website_URL/dev (or your dev name) and ensure you see the "Test Site"
  • Go to website_URL (your production site) and ensure you don't see the "Test Site"
    (If you forgot to change the configuration.php file, the dev site still pointed to the production database, and this last check will save you a boatload of headaches after you've thrashed dev only to figure out you were thrashing the production database!)

YMMV

apache, linux, Joomla!