Install LAMP Stack on a Linux VM in Azure – Part 2

Leave a comment
Azure / Web


In my previous post, I went over how to easily install a Linux VM on Azure. In this tutorial I am going to go over how to install Apache, MySQL, and PHP on your new VM. For this tutorial I will be using PuTTY as my SSH tool. Other tools you can use for this include:  Terminal(MAC), Command Prompt, Open SHH for Windows, Nifty Telnet  SSH just to mention a few. Once you get PuTTY installed you have to connect to the VM using the Host Name or IP address. You can get your Host and IP address which is available on the Azure VM dashboard.


Install Apache

To install apache type the command below

sudo apt-get update

Just incase the above doesn’t work and you happen to get the error below UpdateError This how you fix it

sudo nano /etc/apache2/apache2.conf

Enter the text below

serverName localhost

Save the file by hitting shift O (^o) to write out the file.

Install MySQL Database

Before you type  the command below check for the latest build of MySQL.

sudo apt-get install mysql-server-5.6

InstallPHP Set MySQL “root” user  password EnterrootPWD Confirm Password confirmpwd

Install PHP

If you are reading this in the future please check PHP for the latest stable build .

sudo apt-get install php5 php5-mysql

InstallPHP Enter Y

Create  PHP Test Page

Type the command below.  Vi is a unix editor.  It can be a bit tricky so here is a quick cheat sheet.

sudo vi /var/www/html/test.php

Enter the code below


Open your browser and type in the IP address with test.php file name at the end. This will confirm that PHP is available on your LAMP stack.

Putting it all together

Now Apache, MySQL, PHP are installed on the VM , the next step is to restart Apache so all changes take effect

Start / Stop / Restart Apache

sudo service apache2 start
sudo service apache2 stop
sudo service apache2 restart

Check status

sudo service apache2 status

Start / Stop / Restart MySQL

sudo service mysql start
sudo service mysql stop
sudo service mysql restart

Check status

sudo service mysql status


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>