Skip to content

Instantly share code, notes, and snippets.

@jpalala
Forked from mikepfeiffer/wordpress-linux-azure.sh
Created November 1, 2023 10:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpalala/21c7444b96651a359ff941be6bd0a736 to your computer and use it in GitHub Desktop.
Save jpalala/21c7444b96651a359ff941be6bd0a736 to your computer and use it in GitHub Desktop.
Build a Standalone Wordpress LAMP Server on Azure
#!/bin/bash
# Tutorial: Install a LAMP stack on an Azure Linux VM
# https://docs.microsoft.com/en-us/azure/virtual-machines/linux/tutorial-lamp-stack
# Create the VM Resource Group
az group create --name LAMP-STACK-RG --location westus2
# Create the VM
az vm create \
--resource-group LAMP-STACK-RG \
--name WEB-SRV-001 \
--image UbuntuLTS \
--admin-username azureuser \
--generate-ssh-keys
# Open Port 80 on the Security Group
az vm open-port --port 80 --resource-group LAMP-STACK-RG --name WEB-SRV-001
# Install LAMP
sudo apt update && sudo apt install lamp-server^ -y
# Secure MySQL and set root pwd
sudo mysql_secure_installation
# Validate login to MySQL
sudo mysql -u root -p
# Create PHP Info page
sudo sh -c 'echo "<?php phpinfo(); ?>" > /var/www/html/info.php'
# Install WordPress
sudo apt install wordpress -y
# Create WordPress DB Script
sudo nano wordpress.sql
# CREATE DATABASE wordpress;
# GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER
# ON wordpress.*
# TO wordpress@localhost
# IDENTIFIED BY 'P@ssw0rd2021';
# Configure DB
cat wordpress.sql | sudo mysql --defaults-extra-file=/etc/mysql/debian.cnf
# Remove WordPress DB Script
sudo rm wordpress.sql
# Prep config-default.php file
sudo nano /etc/wordpress/config-localhost.php
# <?php
# define('DB_NAME', 'wordpress');
# define('DB_USER', 'wordpress');
# define('DB_PASSWORD', 'P@ssw0rd2021');
# define('DB_HOST', 'localhost');
# define('WP_CONTENT_DIR', '/usr/share/wordpress/wp-content');
# ?>
# Move the WordPress installation to the web server document root
sudo ln -s /usr/share/wordpress /var/www/html/wordpress
sudo mv /etc/wordpress/config-localhost.php /etc/wordpress/config-default.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment