Hi,
Here is a chapter of an e-book that explains how to create Virtual Hosts to do precisely what you want -- and the examples are using Ubuntu : Creating A Local Domain Using Apache Virtual Hosts
In a few words :
- You first need to create the VirtualHost
- Then, you have to edit your hosts file (under Linux, it's
/etc/hosts
) so the new "pseudo domain name" points to your machine.
For the VirtualHost, with Ubuntu, you'd create a new file in /etc/apache2/sites-available/
; for instance named your-site.com
; it would contain something like this :
<VirtualHost *:80>
ServerName your-site.com
DocumentRoot /.../www/...
<Directory /.../www/...>
Options Indexes FollowSymLinks Includes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
And you register this file so it's loaded by Apache, with this command :
sudo a2ensite your-site.com
And, then, reload Apache :
sudo /etc/init.d/apache2 reload
You then have to edit /etc/hosts to add a line like this :
127.0.0.1 your-site.com
So "your-site.com" actually points to your own computer.
What is important is that the name used to access your website in a browser is the one that is declared in the hosts file ; it also must be the same than the one used by the ServerName directivr in Apache's configuration.
When you have done that for one VirtualHost... It's just the same for every other one : only the name of the site, and it's DocumentRoot, change.
Hope this helps!