Here is the situation;

I have a local development machine where I do my code which running PHP 7 but I'm maintaining PHP 5 application that which I found out some of the component won't work well in newer PHP version.

Vagrant is maybe a good choice but I don't want to stuff up my machine with a lot of tools which troubles me upon Ubuntu upgrade later. Since VirtualBox is a must have tools for me so I decided to tweak only tool I have and make it work.

So here we go. First thing off, we create a new Ubuntu VM inside VirtualBox called it our development machine with php5. I'm using Ubuntu Server 14.04 x64 image and using default options.

undefined

Important part I think matters was package selection so my selection are as follows.

undefined

After installation finish and reboot, login into your VM and do package update;

sudo apt-get update && sudo apt-get upgrade -y

Next, we going to install VirtualBox Guest Additions. Click on Device menu and Insert Guest Additions CD image...

Mount inserted CD to the system

sudo mount /dev/cdrom /media/cdrom

Run the addition's installer

sudo /media/cdrom/VBoxLinuxAdditions.run

Forget about the message it throws regarding cannot find the X.Org, we we're using server edition there is no GUI. Now run poweroff to power down the VM.

Lets take a look ath the VM settings. We need to change two options here.

Network that I've bridged it to my WiFi router.

undefined

Shared Folders to share the root of project directory

undefined

OK and run and login to your VM. If everything goes well you can see your shared folder in /media

 undefined

 Now we check is our LAMP stack is running well. Open up web browser and point to the VM's IP.

 undefined

 Replace default html directory with a symlink from our shared folder.

sudo mv /var/www/html /var/www/html_old
sudo ln -s /media/sf_icetak-dealer /var/www/html

 To make normal user and webserver accessible to the file in shared folder, we need to add our username and Apache's user to vboxsf group then reboot the VM for change to take effect.

sudo usermod -a -G vboxsf <user>
sudo usermod -a -G vboxsf www-data

Now we can browse into our web application.

undefined

Things to go from here:

  • If you web application are using database (MySQL) you need to point database connection configuration using local machine IP instead of localhost (my machine using a fixed IP)
  • We need to create another database user that allows connection from any host. The default root user is locked to only accept connection from local.
  • We need to tweak MySQL's configuration (my.cnf) to allow IP from outside (set bind-address to 0.0.0.0).