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
  • Save jpalala/21c7444b96651a359ff941be6bd0a736 to your computer and use it in GitHub Desktop.
Save jpalala/21c7444b96651a359ff941be6bd0a736 to your computer and use it in GitHub Desktop.

Revisions

  1. @mikepfeiffer mikepfeiffer revised this gist Dec 3, 2021. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions wordpress-linux-azure.sh
    Original file line number Diff line number Diff line change
    @@ -4,18 +4,18 @@
    # 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-DEMO --location westus2
    az group create --name LAMP-STACK-RG --location westus2

    # Create the VM
    az vm create \
    --resource-group LAMP-STACK-RG-DEMO \
    --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-DEMO --name WEB-SRV-001
    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
  2. @mikepfeiffer mikepfeiffer created this gist Dec 3, 2021.
    63 changes: 63 additions & 0 deletions wordpress-linux-azure.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,63 @@
    #!/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-DEMO --location westus2

    # Create the VM
    az vm create \
    --resource-group LAMP-STACK-RG-DEMO \
    --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-DEMO --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