Last active
November 1, 2023 10:44
-
-
Save mikepfeiffer/96d659042f0575a617648a33c92b8f4a to your computer and use it in GitHub Desktop.
Build a Standalone Wordpress LAMP Server on Azure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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