Over the last couple of weeks, I’ve noticed a few issues crop up on the WordPress sites that I manage both for myself and for friends and family. It was the type of issue that if something went wrong on one site, and because I ran them all from a single WordPress Multisite instance, it would break the others and I’d have to restart the cloud-hosted machine each time to try and figure out what was wrong.
After three days of this, I got to the point of just backing up all of the content, setting up a new Docker host and launching individual Apache instances for each site. It turns out this was easier said than done.
I started off by backing up each site with the Prime Mover plugin. I chose this one as not only does it have the ability to backup a multisite install and doesn’t rely on cloud services with limited storage, but that also has the ability to separate each multisite site out into its own backup.
Once that was done for each of the sites the real work began, creating a web server for each website. My original plan was a WordPress docker container and database for each site. Though the initial install went well the issue arose when I tried to restore the sites from their backups. Turns out the prime mover plug-in needs some PHP mods that aren’t included in the standard WordPress image. Try as I might I couldn’t get the required mod to install.
So I launched an Ubuntu image, found a list of every mod needed or suggested for both WordPress and the Prime Mover plug-in and tried again.
The restore worked! Amazing I thought nope it turns out that when I try to write a post about everything that’s happened, the draft won’t save due to the WordPress API not working.
After what felt like an eternity searching for answers it turns out I’d not included a tag in the so-confit file to tell I run SSL, I’d not enabled the mod rewrite module for Apache or enabled the rewrite function in the apache2.conf file either.
After fixing all of that everything now seems to be working as it should. A fair bit of copying and pasting later and I have all of the site running on their own docket container and Cloudflare tunnels managing actually getting everything from the server and onto the web.
I know this is not a very exciting blog post this week but I wanted to share how I finally got everything running correctly in the docker Ubuntu container, and it also makes sure I have this list backed up somewhere too. I’ve listed the commands I used below I hope it helps someone.
/** Installed the required apps and php modules **/
apt update && apt upgrade -y && apt install -y nano curl wget zip unzip apache2 php php-json php-mysqli php-curl php-dom php-exif php-fileinfo php-igbinary php-imagick php-intl php-mbstring php-xml php-zip php-apcu php-memcached php-opcache php-redis php-iconv php-shmop php-simplexml php-xmlreader php-ssh2 php-ftp php-sockets
/** Move into the WWW Directory **/
cd /var/www
/** Remove the default html folder and content **/
rm -r -d html
/**Download the latest version fo WordPress **/
wget https://wordpress.org/latest.zip
/** Unzip the wordpress folder **/
unzip latest.zip
/** Rename the wordpress folder to html **/
mv wordpress/ html/
/** Set the folder permisions **/
chmod 755 -R /var/www/html
/** Start the apache web server - the ubuntu image doens't have systemctl so if you restart your container you'll need to restart apache **/
service apache2 start
/** Start the WordPress setup by entering the details of your database - If used MySQL in a seperate container and making sure that both the MySWL container and WordPress are on the bridged network. I then use the Docker IP of the MySQl container on the WordPress database setup page.
When you have submitted your statbase details do not run the install yet **/
/** Edit the wp-config File to set HTTPS mode and set the FS method to direct stopping any errors when installing plugins and themes. **/
nano /var/www/html/wp-config.php
/** sets HTTPS mode **/
$_SERVER['HTTPS'] = true;
define( 'FS_METHOD', 'direct' );
/** Add the following to .htaccess file - this will increase the default upload limits for plugins, themes and media**/
php_value upload_max_filesize 64M
php_value post_max_size 128M
php_value memory_limit 256M
php_value max_execution_time 300
php_value max_input_time 300
/** Update the /etc/apache2/apach2.conf file to allow the mod rewrite module to work
replace None with all for your website mount point **/
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
/** Enable the Rewrite PHP Module **/
a2enmod rewrite
/** Restart Apache **/
service apache2 restart
/** Continue running the wordpress install as normal **/