Ubuntu LAMP VirtualBox Setup on Windows

This guide includes step-by-step instructions on how to install Ubuntu Desktop in Oracle VM VirtualBox, and the LAMP stack - Linux, Apache, MySQL and PHP 7 to run a basic PHP website.


Install Ubuntu 16.04.1 LTS: Download page. Note the download location (i.e. Downloads, Documents, etc.).

Ubuntu Download Page

Get VirtualBox for Windows: Download page. Choose the download link, x86/amd64 depending on your system. Save the file and run the .exe file.

Follow the VirtualBox installation steps. Once complete, open the application and click, “New”.

Name the operating system – For example, “Ubuntu 16”, then follow the recommended settings to setup the OS.

  • RAM size (1024MB recommended)
  • Create a virtual hard disk now
  • VDI (VirtualBox Disk Image)
  • Dynamically Allocate
  • Select size of virtual hard disk in megabytes – 8.00 GB

Once the initial setup is complete, click “Start” and locate the downloaded Ubuntu ISO file.

Follow the installation steps:

  • Choose language
  • Download updates while installing Ubuntu
  • “Erase disk and install Ubuntu” for clean install
  • Choose location, keyboard layout, username and password
  • Install with updates

Once the full installation is complete, sign in with the username and password entered previously.

Install Guest Additions from “Devices”, then “Insert Guest Additions CD image…”. This optimizes the guest operating system. Reference for Guest Additions: VirtualBox Manual

Follow the prompts to install the additions.

Finally, let’s run a few more commands to check for updates, upgrade packages and install major upgrades. Once this is complete, we are ready to install our web stack.

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get dist-upgrade

LAMP Stack

Install Apache 2

Apache will be our main web server that is used for serving web pages to the client computer.

$ sudo apt-get install apache2

Test to see that Apache installed successfully. Open a web browser and type in your local IP address. To find this, go to System Settings, Network and copy the IPv4 Address number to the browser.

Alternatively, to test in the web browser, go to http://localhost/.

Install MySQL

$ sudo apt-get install mysql-server mysql-client
$ sudo mysql_secure_installation

Install PHP

$ sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql

Test to make sure PHP installed successfully.

$ php -v

PHP 7.0.8-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

Create a new php file:

sudo nano /var/www/html/info.php

Within the editor, include:


type “ctrl + x” to save and quit nano.

Restart Apache:

sudo service apache2 restart

Open a web browser and test with, http://localhost/info.php.