LAMP is an open source Web development platform that uses Linux as the operating system, Apache as the Web server, MySQL as the relational database management system and PHP as the object-oriented scripting language. This article walks you through how to deploy the LAMP stack on an Ubuntu VM in Azure.
Step 1
Create a new Ubuntu Server from the compute category. Fill in the necessary details like Name, Disk Type(SSD/HDD), Username and Password for login credentials, Subscription (if you have multiple), Location and put the associated resources in a new Resource Group.
Step 2
In the second step select the size of the required VM as per your business requirements. You can see what each size offers and how much it costs per month.
Step 3
In the third step you can specify the Availability Zone ( only available in some regions), Availability Set (if required), opt for Managed or Unmanaged Disks ( if unmanaged, have to create a new storage account also), OS Disk size, Virtual Network and Subnet, Network Security Group, Public IP, add any Extensions, enable or disable Auto Shutdown, Boot Diagnostics, Guest OS Diagnostics, Backup ( In this demo we are going with the defaults)
Step 4
On the final step wait for the final Validation to be passed and clicking on create will initiate the deployment of the VM. This may take few minutes and you can check the status from the notification bar.
Step 5
Once the deployment is completed the dashboard for the new VM will be opened. You can access it from the Virtual Machine listing or through Resource Group from the portal. Clickning on Connect option will show the command to connect via the terminal. Here we are using Putty to connect.
Step 6
Copy the Public IP address to the Putty and click on open. Click on yes to add the key to the Putty’s cache as you are logged in for the first time
Step 7
Give the same Username and Password that you assigned while you created the VM. Now you have logged in to your new Ubuntu VM.
Step 8
Now we have Ubuntu and have to install Apache, MySQL, and PHP. Run the following command to update Ubuntu package sources and install the same. It may take few minutes and may ask for permissions in some steps.
- sudo apt update && sudo apt install lamp-server^
Step 9
During the installation it will prompt for the password for the MySQL database. Give the password and you may have to confirm your password.
Step 10
Enable Port 80 by adding an inbound rule in networking tab from portal to allow HTTP requests as our VM is a Web Server. By default, only SSH connections are allowed into Linux VMs deployed in Azure.
Step 11
With Apache installed, and port 80 open to your VM, the web server can now be accessed from the internet. To view the Apache2 Ubuntu Default Page, open a web browser, and enter the public IP address of the VM.
Step 12
To test PHP, create a quick PHP info page to view in a browser by using the following command in the terminal
- sudo sh -c 'echo "<?php phpinfo(); ?>" > /var/www/html/info.php'