Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

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).

share|improve this answer
    
Thanks Sergey, this is clever. –  Tom Brossman Oct 24 '12 at 17:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.