webSIGHTdesigns - Web Design, Web Development, Web Hosting

How to Set up a Local Web Server with Virtualbox on Mac OS X

Posted on Thursday, May 15th, 2014 at 12:00 pm
by webSIGHTdesigns

This tutorial shows how to set up a web server on your localhost using Virtualbox virtual machine.

To develop websites locally you can use the free software Virtualbox to create a virtual machine containing the Linux OS.

Configuring the New Virtual Machine

If you have been provided with a Virtualbox appliance simply navigate to the "Import Appliance" menu option:

File → Import Appliance

Otherwise you will need to download an ISO file of the Ubuntu Server Linux OS. Which version of Ubuntu Server you decide upon may depend on what versions of Apache, PHP & MySQL you plan to support:

Ubuntu Server 12.04:

  • PHP 5.3.10
  • Apache 2.2.22
  • MySQL 5.5.22

Ubuntu Server 12.10:

  • PHP 5.4.6
  • Apache 2.2.22
  • MySQL 5.5.27

Ubuntu Server 13.04:

  • PHP 5.4.9
  • Apache 2.2.22
  • MySQL 5.5.29

Ubuntu Server 13.10:

  • PHP 5.5.3
  • Apache 2.4.6
  • MySQL 5.5.32

Ubuntu Server 14.04:

  • PHP 5.5.6
  • Apache 2.4.7
  • MySQL 5.5.32

Once you've downloaded the ISO file for your chosen Ubuntu Server version, create a new virtual machine:

Machine → New

On the Name and operating system dialog set the Name field to a name you'd like to remeber this virtual machine by. Next set the Type to Linux and the Version to Ubuntu (64 bit) and then click Continue.

On the Memory size dialog, set the amount of your system's RAM (Random Access Memory) that you'd like to set the virtual machine to use.

On the Hard drive dialog, click Create.

On the Hard drive file type dialog, accept the default setting of VDI (Virtual Disk Image) and click Continue.

On the Storage on physical hard drive dialog, accept the default setting of Dynamically allocated and click Continue.

On the File localtion and size dialog, make sure to set the disk space to an amount which will be suitable to your needs. If you'll be developing a lot of sites in this VM they may require more disk space, and you don't want to run out of disk space because resizing the partition later can be problematic. When you're finished, click Create.

Mounting the ISO Disk Image

Before you can install Ubuntu you need to download the ISO file for the version you'd like to install. Downloads are available at:


On the Storage tab, you can mount this ISO file under Controller: IDE by clicking the word "Empty" with the CD icon next to it. Then on the right side where it says CD/DVD Drive click the CD icon to the right and choose the Choose a virtual CD/DVD disk file... option. Lastly, accept these options to proceed and start the VM to run the ISO mounted as a CD in the drive so you can go through the Ubuntu install process.

Configuring Networking

Once you've installed Ubuntu, you'll need to configure networking so you can access your websites from your localhost. In Virtualbox, highlight your VM and click the Settings button. Navigate to the Network tab, and then click the Adapter 2 tab. Set Attached to: to the following:

Host-only Adapter

Now SSH to a terminal on the VM and run:

sudo vi /etc/networking/interfaces

Add the following to the end of the file:

auto eth1
iface eth1 inet static

You can now set up entries in your local machine's /etc/hosts file to create local hostnames by which to access the sites on your VM. Most people use website.localhost but you could use website.ubuntu or something else if you prefer. Add new lines like the following to your /etc/hosts to set this up:


Now just create an Apache VirtualHost by the same name and you can then visit http://website.localhost/ in your local machine's web browser.

Please Sign In

Please sign in to post a comment.

Web Development

View details »

Web Hosting

View details »

Our Portfolio

View portfolio »

WebSight Designs webSIGHTdesigns preferred email webSIGHTdesigns United States United States