How do I set up local Joomla sites for web developing?

I plan to develop multiple websites using Joomla. I'm using Ubuntu Desktop, and only need to access the sites and configuration files locally, while logged in to my user account.

Previously I tried this using tasksel and set up a LAMP server with files in /var/www, but then encountered problems with developing more than one site, and also permissions issues when editing code like CSS files.

How do I set up multiple Joomla sites, each in its own directory and database, for developing on a local desktop machine? Do I even need directories outside of /home?

Related questions here (simplest way to add & edit files in /var/www) and here (avoid sudo when working in /var/www). This might even be a duplicate of one of those, unless there is a simpler solution for web developers.


Solution 1:

I would use Name-based Virtual Hosts support in Apache.

First, you need to modify your /etc/hosts file to add some names which resolve to your local loopback interface:

127.0.0.1       localhost.localdomain   localhost
127.0.1.1       test1
127.0.1.1       test2

Then, in your home directory, you create a directory for your sites, say, sites and a sub-directory for each one:

  sites\
  - test1\
  -- apache_config
  -- www\
  - test2\
  -- apache_config
  -- www\

Each apache_config file would define configuration for each of your virtual hosts:

<VirtualHost *:80>
 ServerName test1
 DocumentRoot /home/username/sites/test1/www
</VirtualHost>

Then you symlink all the configs into /etc/apache2/sites-enabled

ln -s /home/username/sites/test1/www /etc/apache2/sites-enabled/001-test1
ln -s /home/username/sites/test2/www /etc/apache2/sites-enabled/002-test2

Restart Apache.

And that technically should be it - all your sites and their configs are in your home directory, editable by you.

I haven't tested the steps, so it's just a general outline, but that's where I would start. I would avoid placing my work files into /var/www (or using Apache's default virtual host in general), and also I would avoid modifying Apache's main config file (/etc/apache2/apache2.conf) or the default virtual host file (the one in /etc/apache2/sites-enabled/000-default).