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
Once VirtualBox is completed you will see the screen below. We need to choose "New" from the top-left menu.
- Give the setup a name.
- Choose "Linux" as the Type.
- Choose "Other Linux" for the Version.
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.
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.
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.
This is a livecd setup. To finish the installation, you need to choose to install Linux Mint.
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.
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.
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.
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
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.
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!