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?
- Install Apache
- Install PHP
- Open Azure firewall for port 80
- Configure Apache for PHP
- Install mysql
- Install phpmyadmin
- Install FTP Server
- Install JDK 8
- Install Tomcat 8
- Open Azure firewall for port 8080
- Deploy a war file to tomcat
All of the instructions given below assumes you have a SSH connection to your Azure VM.
Apache
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
Trying 127.0.0.1…
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.
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.

PHP
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.

MySQL
ok
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
Trying 127.0.0.1…
Connected to localhost.
Escape character is ‘^]’.
[
5.5.46-0ubuntu0.14.04.2
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)
Tomcat
$ wget http://www.eu.apache.org/dist/tomcat/tomcat-8/v8.0.30/bin/apache-tomcat-8.0.30.tar.gz
$ gunzip apache-tomcat-8.0.30.tar.gz
$ tar -xvf apache-tomcat-8.0.30.tar
$ cd apache-tomcat-8.0.30/bin
$ ./catalina.sh 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
$ ./catalina.sh 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!!

