It all starts here with a craving

1,173 words

Reading time 5 minutes.

A Blog to document our travels

As my partner and I prepare our journey across Asia and Latin America, we decided to document and share some of it on a blog. To be honest, the blog was mostly something I wanted to do, so I will be responsible for the technicalities. I hope I can convince her to write some stories here!

There are a couple of ways to share your travels: messaging apps (WhatsApp), social media apps (Instagram), personal websites, and other creative solutions (Polarsteps, an automatic travel tracker). We are definitely going to text our families, and post pictures in the family WhatsApp group. How are we going to communicate with our extended family and friend? My girlfriend Y. is probably going to be responsible for the social media communication. Since she handles visual content much better than I do, I am left with writing blog posts. You might be wondering why I write in English, although I am French and you probably are too. I have been working in tech in Montreal for a couple of years, and writing in proper French with accents on a Canadian or US keyboard has become increasingly confusing to me. Dear reader, if you follow our adventures, I promise some posts in French are coming.

How do you start a blog? You need some content, of course. But what if you don’t care about traffic and monetizing. Well, I was looking for a website and a server to host it. I considered a few options: coding a simple website (I think I have the skills), using a static website generator like Jekyll, or installing WordPress. One of the main reasons you are currently reading a WordPress blog is because I wanted Y. to easily contribute to it. Then I had to think about hosting this blog. WordPress.com and other Cloud providers offer very competitive Web hosting services for WordPress. For more flexibility, and more work, I chose a virtual private server (VPS) at OVHcloud to host this website. It is located in France to be closer to the primary audience.

From this point on, it could get a bit boring. Feel free to leave.

Here are the characteristics of the server that cost us 5 euros a month including taxes. Y. thinks it is a superfluous expense.

CPU2 vCore
RAM2 GB
Storage40 GB SSD NVMe
Bandwidth500 Mbps unmetered

We got the domain name en-cavale.org at OVHcloud as well. It means “on the run” in French. IPv6 is enabled for the server and the domain name. I had to add an AAAA DNS record. HTTPS has been configured with the installation of a Let’s Encrypt SSL certificate for free.

The server firewall has been configured with the Uncomplicated Firewall (ufw). The password authentication with ssh has been removed. SSH private keys are needed to connect.

Making sure SSL and IPv6 work.

I added some performance monitoring with New Relic for the infrastructure (CPU, memory, storage, etc.) and the WordPress website (transaction time, throughput, errors, etc.).

The WordPress site health checks suggested installing a cache plugin. This type of caching speeds up the load time for most non-logged-in users. When they request a blog post, they are served a static web page (a file which already exists) instead of having to wait for the page to be dynamically generated by the server (PHP code generating HTML). I am using the wp super cache plugin because it is popular and entirely free.

Site Health in the Tools section

Backup

Local and Cloud copies

Backup is manual at the moment. We need to back up the WordPress files in the /srv/www/wordpress folder and the content of the wordpress MySQL database.

On the server:

cd ~/backup
tar -cpzf wp-backup.tar.gz /srv/www/wordpress
sudo mysqldump -u root wordpress > wp_database_backup.sql

Locally, on my laptop:

scp -r ubuntu@en-cavale.org:~/backup/ .

Then, the backup folder is uploaded to the cloud. There are 3 copies: on the server, on my laptop, and on the cloud.

Instead of performing these commands manually, I created a script for that. I still needed to upload the backup manually to the cloud, this could have been automated as well. The process took a lot of time as the website grew in size and the hotel internet connection is sometimes slow. Using the rsync command instead of scp in order to transfer only the difference would have helped for sure.

GitHub

Lately, I am using a GitHub private repo to store the website source files and a dump of the database. I think it is easier and more efficient that what was discussed previously. I must admit, storing a dump of the database in a git repo is not necessarily a good practice. However, it is small (a few megabytes) so it should not be an issue.

I simply run this bash backup script after I complete a blog post:

#!/usr/bin/env bash

# Backup WordPress blog: source files and database.
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
USER_SERVER=ubuntu@en-cavale.org

if [ -z "$1" ]
  then
    echo "Please provide a commit message: e.g. 'post about Varanasi'"
    exit 1
fi

COMMIT_MSG="backup from script: $*"
ssh $USER_SERVER "cd /home/ubuntu/wordpress; sudo mysqldump -u root wordpress > wp_database_backup.sql; ls -lh; git add -A && git commit -m '$COMMIT_MSG'; git push"

Plugin update

The website is located in /srv/www/wordpress on my server. There are two issues if a git repo is created in this folder. First, https://en-cavale.org/.git/logs/HEAD provides some unwanted information, and second, it breaks plugin update.

A solution is to mount /srv/www/wordpress inside your git folder (/home/ubuntu/wordpress). On a Linux server:

mount --bind /srv/www/wordpress /home/ubuntu/wordpress/wordpress

Trying the backup

It is a good idea to try to restore the website from its backup. I did it locally with docker-compose, it involved some tweaking. The wp-config.php file had to be modified, of course. After restoring the database dump, the siteurl and home values in the wp_options table had to be set to http://localhost:8080, etc.

Email Notifications

Email notifications are sent to me when someone is posting a comment, for instance. They are configured using the WP Mail SMTP WordPress plugin (free version) with a free Gmail account. The Akismet Anti-spam: Spam Protection plugin is very necessary once email notifications are enabled.

Analytics

Analytics should work properly with caching. Compare WP Statistics, Google Analytics, umami.

IN PROGRESS

Troubleshooting

The tag pages were not created, and, hence, returning 404 errors. Going to the Settings > Permalink and saving the page without any modification fixed the issue.

Upload size exceeded for media

By default, I could not upload images over 2 MB. There are a couple of methods to mitigate this, I chose the first one here. The limit has been increased to 64 MB by modifying the .htaccess at the root of the WordPress folder.

Image distortion on mobile

If you look at this image on mobile in portrait mode, it might appear to be distorted.

If it has the following settings, for example:

Use the following settings instead to avoid distortion:


Posted

by

To get notified when we publish a new post, sign up to receive an email notification, or subscribe to the RSS feed.

Comments

One response to “It all starts here with a craving”

  1. Rob Avatar
    Rob

    Wow! Amazing!

Leave a Reply

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