How To Set Up Apache Tomcat7 And Ubuntu Virtual Machine On Windows Azure

Windows Azure is a cloud platform where you can build and deploy your applications in Microsoft data centers situated all over the world. Windows azure supports almost  all languages and frameworks. You can create virtual machines with windows and other Linux distros. You can also create websites, mobile services, cloud services, media services and lot more. Here i am going to explain , how to create a Ubuntu 12.04 virtual machine and setting it up with Apache tomcat7 web-server for deploying java based web applications.

Pre-Requirements:

  1. Micrososft Azure account
  2. SSH client putty
Getting Started:

Step 1: Sign in to www.windowsazure.com and click the portal menu at the top right corner.

1

Step 2: Select virtual machine option and click “create a virtual machine”

2


Step 3: There are two options to create a Ubuntu virtual machine. One is quick create, using which you quickly create a new  Ubuntu virtual machine. Second one is creating virtual machine form gallery. If you have pre-configured image of any Ubuntu virtual machine, it will be present inside the gallery. I am going to use the  quick create option since i do not  have any pre-configures images in my gallery.
               
Step 4: Select the quick create option and enter the necessary credentials. First you have to enter the DNS name which will be followed by .cloudapp.net extension. I am going to give comtechies.cloudapp.net. You can choose your own domain name. Secondly select the ubuntu 12.04 image from the given set of images and select the size for your virtual machine. If you are using the trial account you should select the small size. By  default the username is “azureuser”. You have to create password for the azureuser. There are six regions available, you can choose any region. Better is to choose the region nearby your country. Once you finish entering the details click create a virtual machine”. 

3


It will take some time for the virtual machine creation. You can check the status to know if the virtual machine is created or not. Status will be “running” once virtual machine is created.

4

Step 5: Ubuntu server does not have a GUI,  so we have to connect the Ubuntu instance using SSH client putty. Click on the virtual machine and go to the dashboard of the virtual machine to get the public ip and ssh port of  the virtual machine. In the dashboard window , just scroll down a little to get the public ip and ssh port number.

5


Step 6: Connect the Ubuntu instance using putty. Open putty and it the host section give the public ip and in the port , give the port number, which can be obtained from ssh details in the dashboard as shown in the figure above. After entering the necessary details, click open.

6

Step 7: Enter the username as “azureuser” and the password you created at the time of virtual machine creation. Once logged in to the server, you have to update the server using the following command.

sudo apt-get update

Ubuntu will ask password each time when you try to install anything, So you have to add the user to the suoders file.Use the following commands to that.

 sudo su 
visudo

Add the Following code to the sudoers file as shown in the figure below. Save the file after adding the code.

azureuser ALL=(ALL:ALL) ALL

7

Step 7:In-order to access your website through browser , you have to add the http endpoint to the Ubuntu instance. To do that, go to virtual machine dashboard menu and select endpoint. Click “add endpoint” and give the public and private port as 80. You can give any name for the endpoint.

Apache tomcat by default listens to port 8080, so you have to add an endpoint for Apache7 with private and public port as 8080

8

Step 7: Install Apache Tomcat7 using the following command.

sudo apt-get install tomcat7

Now check if the tomcat server is installed properly. To do this enter the public ip followed by the 8080 port number. eg: http://168.83.162.170:8080/ and press enter. If the web page loads and shows a message “It works”, then your Apache server has been configured properly.

Step 8: Install Apache manager using the following command.

sudo apt-get install tomcat7-admin

Step 9: Manager permissions will be restricted by default. So you have to change the user and role in the tomcat-users.xml file. Use the following codes to do that.

cd /etc/tomcat7 
sudo nano tomcat-users.xml

Uncomment the tomcat-users section and add the following code.

<role rolename=”manager-gui”>
<user password=”tomcat” roles=”manager-gui” username=”tomcat”>
</user></role>
Step 9: You can manage apache tomcat 7 through browser using the public ip 
eg : http://168.83.162.170:8080/manager. Username : tomcat  Password : tomcat
0 Shares:
Leave a Reply

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

You May Also Like