Setting up a WordPress website on Azure can be a straightforward process if you follow the right steps. In this blog post, we’ll walk you through the entire process, from creating a virtual machine (VM) to configuring WordPress. By the end, you’ll have a fully functional WordPress site running on an Azure VM.
Step 1: Create a Virtual Machine (VM)
- Create Resource Group:
- Name:
ABCHosting
- Create VM:
- Name:
ABCHostingVM - Region:
Australia Southeast - Image:
Ubuntu Server - Architecture:
X64 - Azure Spot Discount: Enabled
- Size:
D2s_v3(2 vCPUs, 8GB memory) - Authentication: SSH Public Key
- Username:
azureuser - Generate a new key pair: Name it
ABCHosting_VM_key - Open port:
SSH(22) - Disk type: Premium SSD
Step 2: Connect to the VM via SSH
Use the Azure CLI to connect to your VM:
ssh azureuser@<Your_VM_Public_IP> -i <Path_to_Your_Private_Key>
Step 3: Install Prerequisites
Update and upgrade the system packages:
sudo apt update
sudo apt upgrade -y
Step 4: Install Apache
Enable and start the Apache web server:
sudo apt install apache2 -y
sudo systemctl enable apache2
sudo systemctl start apache2
Step 5: Install MySQL/MariaDB
Install MariaDB server and client:
sudo apt install mariadb-server mariadb-client -y
sudo mysql_secure_installation
Step 6: Install PHP and Required Extensions
Install PHP and necessary modules:
sudo apt install php libapache2-mod-php php-mysql php-cli php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip -y
Step 7: Create MySQL Database and User
Access the MySQL shell and create a database and user for WordPress:
sudo mysql -u root -p
In the MySQL shell:
CREATE DATABASE wordpress_db;
CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wordpress_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Step 8: Download and Configure WordPress
Navigate to the web root and download WordPress:
cd /var/www/html
sudo wget https://wordpress.org/latest.tar.gz
sudo tar -xzvf latest.tar.gz
sudo mv wordpress/* .
sudo rm -rf wordpress latest.tar.gz
Step 9: Create Apache Configuration File for WordPress
Create a new Apache configuration file:
sudo nano /etc/apache2/sites-available/wordpress.conf
Add the following content:
<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot /var/www/html
ServerName example.com
ServerAlias www.example.com
<Directory /var/www/html/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Enable the new site and the rewrite module:
sudo a2ensite wordpress.conf
sudo a2enmod rewrite
sudo systemctl restart apache2
Step 10: Configure Firewall Rules
Ensure your firewall rules are correctly set up on the VM:
- Go to Azure Portal:
- Open your web browser and navigate to the Azure Portal.
- Navigate to Your Virtual Machine:
- In the Azure portal, go to “Virtual Machines” and select your VM.
- Network Security Group:
- On the VM’s page, click on “Networking” in the left-hand menu to view the network security group (NSG) associated with your VM.
- Add Inbound Security Rule:
- Click on “Add inbound port rule.”
- Set the “Source” to “Any.”
- Set the “Source port ranges” to “*.”
- Set the “Destination” to “Any.”
- Set the “Destination port ranges” to “80, 443.”
- Set the “Protocol” to “TCP.”
- Set the “Action” to “Allow.”
- Give the rule a name, like “Allow-HTTP-HTTPS.”
- Click “Add” to create the rule.
Step 11: Finalize WordPress Setup
Open your web browser and go to http://<Your_VM_Public_IP>/wp-admin. Follow the WordPress installation wizard:
- Select your language.
- Complete the setup by entering the database details and creating an admin account.
Congratulations! You now have a fully functional WordPress site running on Azure. You can start customizing your website and adding content. If you encounter any issues, feel free to refer back to this guide or consult the official WordPress and Azure documentation for additional support. Happy blogging!



