To configure a LAMP stack (Linux, Apache, MySQL, PHP) on Azure, you can follow these steps:
Step 1: Create a Virtual Machine (VM)
1. Log in to the Azure portal (portal.azure.com).
2. Click on "Create a resource" and search for "Ubuntu Server" or the Linux distribution of your choice.
3. Select the appropriate Linux VM offer and click "Create."
4. Configure the VM settings, including the resource group, virtual machine name, region, and authentication method (SSH public key or password).
5. Choose the appropriate VM size and configure the networking options.
6. Review the configuration and click "Create" to deploy the VM.
Step 2: Connect to the Virtual Machine
1. Once the VM is deployed, open the Azure portal and navigate to the VM's overview page.
2. Click on "Connect" to access the SSH connection information.
3. Use an SSH client (e.g., Terminal on macOS or Linux, PuTTY on Windows) to connect to the VM using the provided SSH command or SSH key.
Example SSH command:
ssh username@public_ip_address
Step 3: Install and Configure LAMP Components
1. Update the package repository and upgrade the system by running the following commands:
sudo apt update
sudo apt upgrade
2. Install Apache:
sudo apt install apache2
3. Start the Apache service:
sudo systemctl start apache2
4. Install MySQL (MariaDB):
sudo apt install mysql-server
5. Secure the MySQL installation:
sudo mysql_secure_installation
For Detailed Instructions Click Here
6. Install PHP and its required modules:
sudo apt install php libapache2-mod-php php-mysql
7. Restart Apache:
sudo systemctl restart apache2
Step 4: Test the LAMP Stack
1. Create a test PHP file in the web server's document root directory:
sudo nano /var/www/html/info.php
2. Add the following PHP code to the file:
<?php
phpinfo();
?>
3. Save the file and exit the text editor.
4. Open a web browser and visit the VM's public IP address or DNS name followed by `/info.php` (e.g., `http://public_ip/info.php`).
5. You should see the PHP information page indicating that your LAMP stack is configured correctly.
That's it! You have successfully configured a LAMP stack on an Azure virtual machine.