Ubuntu 18.04 in Azure – Pt. 5: WordPress

The piece de resistance of this series has arrived! With all of the prerequisites met for WordPress and my own tinfoiled-hat nature, it’s time to let our hair down, throw caution to the wind, and install the most exploited (yet allegedly secure) blogging platform on the planet!

Based on my research, it’s largely older and unpatched instances that are exploited or ones heavily laden with every plugin available both helpful and unnecessary. Also, having unique credentials created for each and every login will help in the event that one of the few plugins I do use is hacked and those credentials pilfered.

…on a somewhat related note, isn’t pilfered a great word!?

mysql -u root -p
Provide the root password created during MySQL install previously.
mysql> CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
mysql> GRANT ALL ON wordpress.* TO ‘<uniquewordpressusername>’@’localhost’ IDENTIFIED BY ‘<uniqueWPpassword>’;
mysql> FLUSH PRIVILEGES;
mysql> EXIT;

Install PHP extensions needed by WordPress
sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip
sudo systemctl restart apache2

sudo nano /etc/apache2/sites-available/<yourdomain>.conf
Add in the following lines:
<Directory /var/www/<yourdomain>/>
AllowOverride All
</Directory>

sudo a2enmod rewrite
sudo systemctl restart apache2

Ok…so I lied before! Now it’s time to install WordPress!

cd /tmp
curl -O http://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz
touch /tmp/wordpress/.htaccess
cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php
mkdir /tmp/wordpress/wp-content/upgrade
sudo cp -a /tmp/wordpress/. /var/www/<yourdomain>
sudo chown -R www-data:www-data /var/www/<yourdomain>
sudo find /var/www/<yourdomain>/ -type d -exec chmod 750 {} \;
sudo find /var/www/<yourdomain> -type f exec chmod 640 {} \;

curl -s https://api.wordpress.org/secret-key/1.1/salt/
Make a note of the provided unique values. They are one-time use and should not be shared. If you do not make a note of the values, re-run the command and be sure to copy the values somewhere safely for transcribing next.

sudo nano /var/www/<yourdomain>/wp-config.php
Find the section that contains the dummy values for the unique values provided previously and replace them accordingly.
While in the same wp-config.php file, replace the database connection settings as appropriate.

Now, with everything configured, it is time to complete the install from the WebUI.
Navigate to https://<yourdomain> and the installer wizard will proceed automatically.

This concludes the setup “instructions” for the Azure instance currently running this blog. Total cider count in writing all segments in one sitting: 3. Currently enjoying Downeast Cider. Between the Original Unfiltered, Double Filtered, and the seasonal White I am definitely enjoying myself!

Leave a Reply

Your email address will not be published. Required fields are marked *