Ok, I'm not a programmer, and I'm not a linux systemadminstrator. But as a webdeveloper I do need a Lamp-server with virtual host setup on my desktopmachine. And I could not find any up-to-date step by step manual. So for my own sake: here I'll give it a try.
I have a fresh and default install of Ubuntu 9.10. And I want a simple to manage development setup for websites using PHP5 and MySQL5. So lets start with installing a complete LAMP-server setup the Ubuntu-way:
http://ubuntuguide.net/the-easiest-way-installing-lamp-server-in-ubuntu.This works for me, http://localhost gives me back a nice apache-page telling me I have a running webserver.
Now the other part: mass virtual hosting. This is actually quite simple.....once you have done it once!!
Use your favorite editor to open the apache2 configfile, I use jed:
sudo jed /etc/apache2/apache2.conf
On the bottom add:
<VirtualHost 127.0.0.1>
UseCanonicalName Off
VirtualDocumentRoot /var/www/%0
</VirtualHost>
This tells apache to look for folders in /var/www and use them as a root folder for a website.
Next we need to load the apache-module to support virtual hosting this way. You can find all available modules in /etc/apache2/mods-available. In my case the last module I need to load: vhost_alias.load.
sudo a2enmod vhost_alias
Lets restart apache to activate the module and the modified configuration:
sudo /etc/init.d/apache2 restart
Last thing we need to do now is add a website folder to /var/www and add the name to our host-file:
sudo mkdir /var/www/test.dev
sudo chown user:user /var/www/test.dev
Replace user here with your username, so you can edit the files as a normal user.
sudo jed /etc/hosts
and add test.dev right behind your localhost
127.0.0.1 localhost test.dev
Now you should be up and running. I always start putting my php info file to test:
jed /var/www/info.php
and add:
<? phpinfo(); ?>
Go to your browser, and open http://test.dev/info.php. This should show you the informationpage.