Here's how I do setup a Name-based virtual website on my Ubuntu laptop

First on terminal, install the LAMP parts\\
<code>
sudo apt-get install lamp-server^ php5 php5-curl php5-gd php5-mysql php5-cli php5-cgi
</code>
Then add your user to the www-data group

<code>sudo usermod -a -G www-data <your user name></code>

Create a folder for your virtual website say mywebsite.local by\\
<code>
mkdir -p ~/Websites/mywebsite.local/public_html/cgi-bin
mkdir -p ~/Websites/mywebsite.local/logs
</code>

now add the ~/Websites/ folder to the www-data group
<code>sudo chgrp -R www-data ~/Websites</code>

and give write permissions
<code>sudo chmod -R g+w ~/Websites</code>

You can also do the same with the default web directory /var/www so that the default will work
<code>
sudo chgrp -R www-data /var/www
sudo chmod -R g+w /var/www
</code>

Copy the file ''default'' from /etc/apache2/sites-available to ''mywebsite.local''\\
Edit ''mywebsite.local'' as below - remember to add the ServerName line\\

<code>
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName mywebsite.local

DocumentRoot /home/user/Websites/mywebsite.local/public_html
<Directory /home/user/Websites/mywebsite.local/public_html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /home/user/Websites/mywebsite.local/public_html/cgi-bin/
<Directory "/home/katherine/Websites/mywebsite.local/public_html/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog /home/user/Websites/mywebsite.local/logs/error.log

# Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
LogLevel warn

CustomLog /home/user/Websites/mywebsite.local/logs/access.log combined

</VirtualHost>
</code>

**UPDATE** The latest Apache has changed the above config file so it's now\\
The filename will be\\
**mywebsite.local.conf**\\
and the config file
<code>
<VirtualHost *:80>
	# The ServerName directive sets the request scheme, hostname and port that
	# the server uses to identify itself. This is used when creating
	# redirection URLs. In the context of virtual hosts, the ServerName
	# specifies what hostname must appear in the request's Host: header to
	# match this virtual host. For the default virtual host (this file) this
	# value is not decisive as it is used as a last resort host regardless.
	# However, you must set it for any further virtual host explicitly.
	ServerName mywebsite.local

	ServerAdmin webmaster@localhost
	DocumentRoot /home/dan/Websites/mywebsite.local/public_html
	<Directory /home/dan/Websites/mywebsite.local/public_html/>
	Options All
	AllowOverride All
	Require all granted
	</Directory>

	ScriptAlias /cgi-bin/ /home/dan/Websites/mywebsite.local/public_html/cgi-bin/
	<Directory "/home/dan/Websites/mywebsite.local/public_html/cgi-bin">
	Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
	AllowOverride None
	Require all granted
	</Directory>

	# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
	# error, crit, alert, emerg.
	# It is also possible to configure the loglevel for particular
	# modules, e.g.
	#LogLevel info warn

	ErrorLog /home/dan/Websites/mywebsite.local/error.log
	CustomLog /home/dan/Websites/mywebsite.local/access.log combined

	# For most configuration files from conf-available/, which are
	# enabled or disabled at a global level, it is possible to
	# include a line for only one particular virtual host. For example the
	# following line enables the CGI configuration for this host only
	# after it has been globally disabled with "a2disconf".
	Include conf-available/serve-cgi-bin.conf
</VirtualHost>
</code>\\

Now enable the site ''sudo a2ensite mywebsite.local''\\
and reload apache2 by ''sudo service apache2 restart''\\

To point your browser to the localhost address for the website\\

<code>sudo gedit /etc/hosts</code>
and add a space after ''127.0.0.1 localhost'' with ''mywebsite.local'' and a blank line after\\

You could put a test index file in the new webiste like this\\
<code>
<html>
  <head>
    <title>mywebsite.local</title>
  </head>
  <body>
    <h1>Success: You Have Set Up a Virtual Host</h1>
    <?php phpinfo(); ?>
  </body>
</html>
</code>

Save it as ''index.php'' in the virtual document root and view it in your browser by typing ''http://mywebsite.local''\\

Install ''phpmyadmin'' to have an easy way to create/modify your MySQL database by\\
<code>sudo apt-get install phpmyadmin</code>

Access is via the browser with URL ''http://localhost/phpmyadmin''


