Set up a LAMP Stack with Linux and VirtualBox

Set up a LAMP Stack with Linux and VirtualBox
In this tutorial, I’m going to show you how to set up a LAMP stack inside a Windows container.

Recently, an OSTraining member was moving from Windows to Linux. They wanted help to set up their development environment and I recommend VirtualBox.

With VirtualBox, you can set up a development environment in under an hour and it will run flawlessly.

We’re also going to use Linux Mint in this tutorial. These steps work with Ubuntu also, but Mint has a slightly easier interface, particularly for Windows users.

Getting started with VirtualBox

Go to the VirtualBox website and download the VirtualBox for your OS. you will also need to download the ISO for Linux. For the purpose of this tutorial, we will be using the Mint 64bit Cinnamon.

Getting started

Once VirtualBox is completed you will see the screen below. We need to choose “New” from the top-left menu.

Install VirtualBox
  • Give the setup a name.
  • Choose “Linux” as the Type.
  • Choose “Other Linux” for the Version.
Configuring the container

Here you have to decide how much free RAM you can dedicate to your setup. You can see that it only wants 512MB, but any extra RAM you can assign will help the setup run quicker. Personally, I set this to 2000 MB.

Setting memory dedicated to your virtualbox

You now have a choice of options for your virtual machine hard drive. I recommend creating a virtual hard drive as it tends to operate better. Plus, if you remove this later, it won’t leave any redundant files hanging around. The next screen will give you a choice of virtual disks. Using the default is recommended.

Configuring your hard drive for virtualbox
Now we configure how the virtual drive will operate. I recommend leaving the drive as a “Dynamically allocated” so you don’t have to worry about wasting space. On the following screen, you can choose how much space you want to assign by default. 8 gig is the amount allocated and since the drive will adjust as needed you don’t really need to change this.

Configure how the virtual drive will operate

Begin installing Linux Mint

Click “Start” and the VirtualBox will start. You will be prompted for the start-up disk: select the ISO file for linux that we downloaded earlier.

Begin installing mint

This is a livecd setup. To finish the installation, you need to choose to install Linux Mint.

Completing installation

Using Terminal

Now that we have set up Linux, it’s time to get used to using Terminal, which is the default way of issuing commands for Linux.

Open Terminal from the menu bar and enter sudo apt-get install php5 mysql-server apache2.

Using Terminal
You will be asked to provide your password. Then select Y to continue.

Installing the LAMP stack

Checking the LAMP stack is working

Now go to your browser and enter localhost. You should see the screen below. Ubuntu and Mint both share repositories and this tutorial should work just as well for Ubuntu as it does for Mint. Now we know Apache is working.

Next, we need to check that PHP is working. Let’s create the PHP test page.

Checking the LAMP stack is working

Go back to terminal and enter “sudo nano /var/www/html/test.php”.

Nano is a text editor we are going to use to make the test page. In the new screen enter <?php phpinfo(); ?> and holding control down press x and save the file. Now if we navigate to localhost/test.php we should see the configuration for PHP. If you see the image below then congratulaions – you have set up a Mint Linux development environment.

Making a php test page

Now that we have the LAMP set up, from time to time you will want to go directly to the folder to make changes. By default the primary user is not granted permissions to change files in this location, so we have to tell Mint who will control the folder and all subfolders. We do this with the following command: sudo chown -R daniel /var/www/html

Changing ownership of the folder

Installing phpMyAdmin

Finally, we are going to install phpMyAdmin to make using MySQL easier.

Go to the phpMyAdmin page on the Linux Mint website. Simply click install. You will be asked to choose Apache and set a password.

Installing phpmyadmin

In your browser, navigate to localhost/phpmyadmin and you should see the screen below. You will have to login using root and the password you set for your phpMyAdmin.

Congratulations, you now you have a fully functional LAMP setup with phpMyAdmin!

Checking phpmyadmin is working


0 0 votes
Blog Rating
Notify of
Newest Most Voted
Inline Feedbacks
View all comments
John Quinlan

Thanks, this was exactly what i was looking for….


You are welcome John.


great , but if we need access with ftp, how work ?


Hi tmex,
FTP to what the local dev ? You should be fine just dropping the files in the correct place you can install filezilla for linux if you want a FTP client that is similar to windows.


Great article, thanks. I realize I am commenting 7 months later, but wouldn’t PHP 7 be the version to install, instead of PHP 5?

kerry ruddock

Hi Daniel,
I am following along in setting up LAMP stack and I was at the point where I am trying to create the

test.php file. Add your command and get this error when trying to save the file.

Error writing /var/www/html/test.php: No such file or directory
I am thinking its a permissions thing. Any ideas how to overcome this problem?

kerry ruddock

Not really sure what happened, Apparently, I needed to re-install apache2. All is working.


thanks , but it was more interesting if you create a virtual machine from a server version of Linux as guest machine and accessing it from host machine 🙂


Hi Mostafa,
That really would be overkill. You just need to SSH, rysnc or use git to push pull changes to a server


anyone doing this now and experiencing php not parsing – try installing the libapache2-mod-php7.0 (if using php7 obviously)

Would love your thoughts, please comment.x