Setting Up A Testing Environment For PHP Using VirtualBox - Part 1 Installing VirtualBox

Setting Up A Testing Environment For PHP Using VirtualBox - Part 1 Installing VirtualBox

In this tutorial I will show you how to download and install VirtualBox for your development environment. This is a software virtualisation package which we install on our computer, and through VirtualBox we can then install other operating systems and run them ‘natively’. So we can run a Linux server on a Windows machine. We do this for a few reasons:

  1. Every computer is different with regard to software, hardware and operating systems.
  2. Differences with your computer and the target server can be reduced by mimicking the server and running our test code on our test server.
  3. Cuts down the cost of not having to hire webspace or rent a cloud server.
  4. Allows us to have the exact same server configuration as our as the target server.

Installing the Required Software

To get our environment up and running we will need to first download the software from, you should choose the binary that corresponds to your operating system. If you are running a Windows OS then click the Windows hosts link and if you are running OS X then click the OS X link, as I am using OS X then that’s the one I will download the download a copy of Ubuntu Server from

Creating your virtual machine

First install VirtualBox the usual way you instal programs on your computer, once installed start the program and you should see a window like

Capto_Capture-2016-12-06_10-40-43_am.pngTo make your new virtual machine click 'New' and you will be presented with a new box entitled 'Name and operating system', fill the name out to 'Ubuntu Server' and 'Type and 'Version' should be automatically selected like below, we want the 'Type' to be 'Linux' and the 'Version' to be 'Ubuntu (64-bit)' if they are not selected then go ahead an manually select them

Next click 'Continue' and the next window entitled 'Memory size'. This option is how much RAM we are to allocate to our Ubuntu Server the default is 1024MB so if you have quite a bit of RAM then you can add more but don't go into the red area on the slider like below
Click 'Continue' and the next option is the 'Hard disk' make sure you have the 'Create a virtual hard disk now' and click 'Create'
Capto_Capture-2016-12-06_10-42-33_am.pngThe next window is 'Hard disk file type' just keep the default option of 'VDI (VirtualBox Disk Image)' and click 'Continue'

Capto_Capture-2016-12-06_10-42-53_am.pngThe next option is '' this option is how much space the virtual hard drive will take up on your physical hard drive, I would leave it on the 'Dynamically allocated' option as this will grow the dark drive to it's maximum limit you set, so if at the end of install the space taken by the files on the server is 3 GB then that's the physical size the image on your hard drive will be and will grow up to the maximum.

Capto_Capture-2016-12-06_10-43-05_am.pngClick 'Continue' and and the next window is 'File location and size' here we define which folder to put our image the default is the name of our server which is fine and select how much space the hard drive will grow to the minimum is 8 GB but you can give to more if you wish.

Capto_Capture-2016-12-06_10-43-39_am.pngClick 'Create' and it will create the virtual machine. When done you should have something similar to the picture below

Capto_Capture-2016-12-06_10-44-08_am.pngJust a few more settings to adjust and then it's done, so with your Ubuntu Server selected click settings and in the new window entitled 'Ubuntu Server - General' click the 'System' icon and then the 'Processor' option if you have a quad core or more computer you can add more cpu resources to your virtual machine here as I have eight cpus I will increase this value to 4, but don't increase passed the red area as this will just slow things down.

Capto_Capture-2016-12-08_10-33-35_pm.pngNext click 'Display' icon and this option you can increase the video memory but as we are not using a desktop we can keep this low to say 12 MB

Capto_Capture-2016-12-06_11-22-13_am.pngNext we have to add your Ubuntu live disk so we can install the system so click 'Storage' and select the 'Empty' disk icon under 'Controller.IDE' in the 'Storage Tree' panel then on the right under 'Attributes select the disk icon and add the iso you downloaded from Ubuntu by selecting the 'Choose Optical Disk File' option.

Capto_Capture-2016-12-06_11-20-35_am.pngJust one more option to adjust so select the 'Network' icon and here we configure the network adapter the default is 'NAT' which means it will be allocated an IP on a new subnet of your network like '' but we want it on the same subnet as our host computer so change the 'Attached To' option to 'Bridged Network' and choose the name of your hosts network adapter, if you are using WiFI to connect to the router choose that or the Ethernet option

Capto_Capture-2016-12-06_11-19-26_am.pngAnd that's it, click 'OK' and we are ready to power our virtual machine up.

Installing the Ubuntu Server will be in part 2 of this series. I have made a video tutorial to company this series so if you would like to check it out.

Watch on youtube: Setting Up A Testing Environment For PHP Using VirtualBox - Part 1 Installing VirtualBox

hope you enjoyed this tutorial and as always happy coding!

09/12/2016 08:53:00 Shaun Freeman Filed Under: Virtual Box

Twitter Feed
Shaun Freeman @Zendmaster

Shaun Freeman @Zendmaster

Fixing PHP OPcache mysql_xdevapi Uncaught Error: Call to a member function limit()

Shaun Freeman @Zendmaster

I liked a @YouTube video 8 super heroic Linux commands that you probably aren't using

Shaun Freeman @Zendmaster

I liked a @YouTube video How to Maximize Your Productivity (As a Software Developer or Learning Programming)

Shaun Freeman @Zendmaster

I liked a @YouTube video From Carnivore Diet to Near-Death: Lessons Learned From Today's Most Popular Fad Diet

Shaun Freeman @Zendmaster

I liked a @YouTube video Carnivore Diet – Myths about Meat – Phil Escott – WHIS 2018