Setting up Ubuntu VM in Azure cloud for PHP & Java development

This step by step guide will be helpful to understand how to setup LAMP with tomcat on a fresh Ubuntu Azure VM

What are we going to do?

  1. Install Apache
  2. Install PHP
  3. Open Azure firewall for port 80
  4. Configure Apache for PHP
  5. Install mysql
  6. Install phpmyadmin
  7. Install FTP Server
  8. Install JDK 8
  9. Install Tomcat 8
  10. Open Azure firewall for port 8080
  11. Deploy a war file to tomcat

All of the instructions given below assumes you have a SSH connection to your Azure VM.



sudo apt-get install apache2

Let’s start apache service

pandian@grassfield:~$ sudo /etc/init.d/apache2 start
* Starting web server apache2                                                   *

Is it listening to port 80?

pandian@grassfield:~$ telnet localhost 80
Connected to localhost.
Escape character is ‘^]’.

Let’s open the port 80 with azure firewall.

Goto Network security groups


You will find you security group. If you don’t find any, add one.04

This is your essential settings. Click on Inbound security rules


You will find the rules created already. Here is the one created for SSH access.


Allowed TCP Port 80


Try to browse your public IP on your browser.



sudo apt-get install php5

Let’s test php now.

$ cd /var/www/html/

$ sudo mkdir testphp

$ sudo  chmod 777 testphp/

$ cd testphp/

$ vi index.php


Try to browse your url.




Lets install mysql and its connectors now

$ sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql

Lets’s start it now.

pandian@grassfield:~$ sudo /etc/init.d/mysql start
* Starting MySQL database server mysqld                                 [ OK ]

Check the port is open

$ telnet localhost 3306
Connected to localhost.
Escape character is ‘^]’.

Lets install phpmyadmin now. Otherwise, I’ll feel handicapped as many other developers

sudo apt-get install phpmyadmin

Lets test if this is accessible.


Java SDK

We can install Open JDK, But I wanted to use the oracle jdk. Hence I downloaded and transferred the .tar.gz file using SCP.

$ wget http://xxxxxxxxxxxxxxxxxx/jdk-8u65-linux-x64.tar.gz

$ gunzip jdk-8u65-linux-x64.tar.gz

$ tar -xvf jdk-8u65-linux-x64.tar

$ jdk1.8.0_65/bin/java -version
java version “1.8.0_65”
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)


$ wget

$ gunzip apache-tomcat-8.0.30.tar.gz

$ tar -xvf apache-tomcat-8.0.30.tar

$ cd apache-tomcat-8.0.30/bin

$ ./ start
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program

$ export JAVA_HOME=/home/pandian/jdk1.8.0_65

$ ./ start              Using CATALINA_BASE:   /home/pandian/apache-tomcat-8.0.30
Using CATALINA_HOME:   /home/pandian/apache-tomcat-8.0.30
Using CATALINA_TMPDIR: /home/pandian/apache-tomcat-8.0.30/temp
Using JRE_HOME:        /home/pandian/jdk1.8.0_65
Using CLASSPATH:       /home/pandian/apache-tomcat-8.0.30/bin/bootstrap.jar:/home/pandian/apache-tomcat-8.0.30/bin/tomcat-juli.jar
Tomcat started.

Make sure tomcat is started

tail ../logs/catalina.out

09-Jan-2016 11:34:16.126 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 5799 ms

Okay! Ready!!





Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s