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.
To install apache type the command below
sudo apt-get update
sudo nano /etc/apache2/apache2.conf
Enter the text below
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
If you are reading this in the future please check PHP for the latest stable build .
sudo apt-get install php5 php5-mysql
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
<?php phpinfo(); ?>
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
sudo service apache2 status
Start / Stop / Restart MySQL
sudo service mysql start
sudo service mysql stop
sudo service mysql restart
sudo service mysql status