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/danpercival.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>

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''


