Register for the iXsystems Community to get an ad-free experience and exclusive discounts in our eBay Store.
Scripted WordPress Installation (for Reverse Proxy)

Scripted WordPress Installation (for Reverse Proxy) 2.3.1

Western Digital Drives - The Preferred Drives of FreeNAS and TrueNAS CORE

Basil Hendroff

Neophyte Sage
Joined
Jan 4, 2014
Messages
1,303
Basil Hendroff submitted a new resource:

Scripted WordPress Installation - Script to create an iocage jail for the latest WordPress release, including Caddy, MariaDB and PHP.

If the statistics are to be believed, in 2020:
  1. WordPress powers 35% of the internet.
  2. Around 60% of CMS sites are WordPress.
  3. Around 28% of WordPress sites run e-commerce.
  4. Around 75% of hacked CMS sites were built on WordPress.
There are few current guides on the forum for setting up WordPress and none are scripted. While there's still an element of manual post-installation work, this guide is...
Read more about this resource...
 

NasKar

Neophyte Sage
Joined
Jan 8, 2016
Messages
694
I learned a few things looking thru your script. Thanks for sharing. Do you know if you can backup the apps/wordpress/db and apps/wordpress/files directories. Then install wordpress from scratch and restore the db and files directories? Or do you have to use mysqldump to backup the db?
 

Basil Hendroff

Neophyte Sage
Joined
Jan 4, 2014
Messages
1,303
Do you know if you can backup the apps/wordpress/db and apps/wordpress/files directories. Then install wordpress from scratch and restore the db and files directories? Or do you have to use mysqldump to backup the db?
At this stage, as you're probably aware, the script will only work with new installations and will not overwrite existing data outside the jail. There are a couple of reasons for this. The first is, to ensure that WordPress data outside the jail is never overwritten as a result of rerunning the script; the second is, recovery strategies are as yet not well defined or are largely untested.

In this instance, I think there's a simpler approach to addressing your query; the theory is sound, but it's untested. The infographic below will clue you in on what needs to happen.

screenshot.731.png


You might like to try it. If it all goes belly-up, you need to be prepared to rebuild from scratch. If it's successful, then at least we know it's a strategy that will work under certain scenarios.

I'm currently testing an approach that leaves little room for error and that will apply in a wide range of recovery scenarios, including this one, but it isn't yet ready for general release.
 
Last edited:

Basil Hendroff

Neophyte Sage
Joined
Jan 4, 2014
Messages
1,303
Do you know if you can backup the apps/wordpress/db and apps/wordpress/files directories. Then install wordpress from scratch and restore the db and files directories? Or do you have to use mysqldump to backup the db?
A WordPress site is made up of a number of elements that work closely together including the database, plugins, themes, uploads and others. In this context, backing up just the database has limited value.

The infographic below describes a streamlined approach to WordPress disaster recovery that minimises the room for error, and maximises the chances of fully restoring a WordPress site under a wide range of WordPress disaster scenarios, including the one described in the previous post.

screenshot.733.png


I've tested the approach against my own blog site and apart from a minor tweak of WP Super Cache, a WordPress caching program that works deep in the WordPress core, the whole restoration process went very smoothly. The longest part of the process was actually running the installation script to create the WordPress jail. Once I got into WordPress and installed and configured the UpdraftPlus backup/restore plugin, the actual restoration of the WordPress site happened very quickly.

The free version of UpdraftPlus works just fine for this. The only caveat is that you must restore the site to the same subdomain/subfolder structure i.e. you can't in the process move the site from say site1.mydomain.com to site2.mydomain.com. While not necessary for disaster recovery, the premium version of UpdraftPlus will allow you to duplicate or migrate websites if you want this feature.

To set up UpdraftPlus to use FTP storage on FreeNAS/TrueNAS for backup, refer to the blog post WordPress Plugin: A Marriage made in Heaven for UpdraftPlus and FreeNAS. I've not (yet) described the restoration process, so I strongly urge anyone using this approach to test out the restore phase so that you're familiar with this phase and to reassure yourself of the validity and integrity of the approach. You should, on a periodic basis, retest this phase.

EDIT: A must-read official resource WordPress Backups
 
Last edited:

NasKar

Neophyte Sage
Joined
Jan 8, 2016
Messages
694
I have a script that creates a dump of the wordpress database and tars that with the wordpress files with it. It will restore from scratch. My setup has just the wordpress files in my pool/apps/wordpress directory. I'll try to modify it to work with your setup of the apps folder and share it with you. It also creates backups of the other directories in the apps/ folder.

Is there a benefit to having the database files mounted to apps/db?
 

Basil Hendroff

Neophyte Sage
Joined
Jan 4, 2014
Messages
1,303

Basil Hendroff

Neophyte Sage
Joined
Jan 4, 2014
Messages
1,303
Basil Hendroff updated Scripted WordPress Installation with a new update entry:

Caddy 2.2.0 released

A Caddy web server serves the PHP files in the WordPress jail. Caddy has been upgraded overnight from v2.1.1 to 2.2.0.

To update your WordPress jail if you've previously run v1.0.0 of the script:
  1. Assuming the jail is named wordpress, enter the jail iocage console wordpress
  2. Install the PHP xmlwriter extension pkg install php74-xmlwriter
  3. Update Caddy.
Code:
cd /usr/local/bin​
...
Read the rest of this update entry...
 

Basil Hendroff

Neophyte Sage
Joined
Jan 4, 2014
Messages
1,303
Basil Hendroff updated Scripted WordPress Installation with a new update entry:

Include phpMyAdmin in the WordPress jail

The phpMyAdmin program is handy for performing maintenance operations on tables, backing up information, and editing things directly in the event that WordPress is not working. It is referenced quite frequently in WordPress documentation and has been included in this release.

To update your WordPress jail if you've run the previous script version 1.2.3 of the script, enter the jail iocage console wordpress and execute the following commands:

Code:
pkg install...
Read the rest of this update entry...
 

Basil Hendroff

Neophyte Sage
Joined
Jan 4, 2014
Messages
1,303
Basil Hendroff updated Scripted WordPress Installation with a new update entry:

Install Redis for server-side caching

Unlike cache plugins, that run from inside the WordPress site and provide frontend caching, Redis is a server-side cache.

To update your WordPress jail if you've run the previous version 1.3.0 of the script, enter the jail iocage console wordpress and execute the following commands:

Code:
pkg update
pkg install redis php74-pecl-redis

Edit the file redis.conf cd /usr/local/etc && ee redis.conf. To reconfigure Redis to listen on a Unix socket rather...
Read the rest of this update entry...
 

Basil Hendroff

Neophyte Sage
Joined
Jan 4, 2014
Messages
1,303
Basil Hendroff updated Scripted WordPress Installation with a new update entry:

Caddy 2.2.1 released

A Caddy web server serves the PHP files in the WordPress jail. Caddy has been upgraded from v2.2.0 to 2.2.1.

To update your WordPress jail, assuming the jail is named wordpress, enter the jail iocage console wordpress and update Caddy:

Code:
cd /usr/local/bin
fetch https://github.com/caddyserver/caddy/releases/latest/download/caddy_2.2.1_freebsd_amd64.tar.gz
caddy version #2.2.0
service...
Read the rest of this update entry...
 

Basil Hendroff

Neophyte Sage
Joined
Jan 4, 2014
Messages
1,303
Basil Hendroff updated Scripted WordPress Installation with a new update entry:

Auto-configuration of wp-config.php

Fewer manual post-installation steps are required in this release. The initial configuration of the WordPress configuration file wp-config.php has been fully automated. Previous manual post-installation that are now redundant include:
  1. Configuring WordPress behind a reverse proxy;
  2. Setup of the WordPress filesystem; and
  3. Configuring Redis.
In addition, this release adds to wp-config.php:
  1. Debug support; and
  2. WP Super Cache...
Read the rest of this update entry...
 

Basil Hendroff

Neophyte Sage
Joined
Jan 4, 2014
Messages
1,303
Basil Hendroff updated Scripted WordPress Installation with a new update entry:

Auto-configuration of mailer.conf

One less manual post-installation step to undertake. The configuration of the sendmail file /etc/mail/mailer.conf has been automated. The post-installation tasks for setting up and testing sSMTP has been revised to reflect this change.

There are no changes to the jail between versions 1.4.4 and 1.4.5 of this resource. This revision streamlines the installation phase by having the script do more while further reducing the need for manual post-installation intervention.
Read the rest of this update entry...
 

Basil Hendroff

Neophyte Sage
Joined
Jan 4, 2014
Messages
1,303
Basil Hendroff updated Scripted WordPress Installation with a new update entry:

Auto-secure the WordPress database.

Manually securing MariaDB is no longer necessary. The steps to do this have been merged into the installation script. Instructions for manual post-installation tasks have been revised to reflect this change.

There are no changes to the jail between versions 1.4.5 and 1.4.6 of this resource. This revision streamlines the installation phase by having the script do more while further reducing the need for manual post-installation intervention.
Read the rest of this update entry...
 

Basil Hendroff

Neophyte Sage
Joined
Jan 4, 2014
Messages
1,303
Basil Hendroff updated Scripted WordPress Installation with a new update entry:

Auto-generate Authentication Unique Keys and Salts

Manually generating Authentication Unique Keys and Salts is no longer necessary. The steps to do this have been merged into the installation script. Instructions for manual post-installation tasks have been revised to reflect this change.

There are no changes to the jail between versions 1.4.6 and 1.4.7 of this resource. This revision streamlines the installation phase by having the script do more while further reducing the need for manual post-installation intervention.
Read the rest of this update entry...
 

Basil Hendroff

Neophyte Sage
Joined
Jan 4, 2014
Messages
1,303
Basil Hendroff updated Scripted WordPress Installation with a new update entry:

Auto-configuration of phpMyAdmin

It's no longer necessary to configure phpMyAdmin manually. An improved password algorithm has been adopted for the script. The number of manual post-installation tasks is now at a minimum.

There are no changes to the jail between versions 1.4.7 and 1.4.8 of this resource. This revision streamlines the installation phase by having the script do more while further reducing the need for manual post-installation intervention.
Read the rest of this update entry...
 

Basil Hendroff

Neophyte Sage
Joined
Jan 4, 2014
Messages
1,303

Basil Hendroff

Neophyte Sage
Joined
Jan 4, 2014
Messages
1,303
Basil Hendroff updated Scripted WordPress Installation with a new update entry:

phpMyAdmin database

Create and configure a phpMyAdmin database to store configuration data.

To update your WordPress jail wordpress if you've run the previous version 1.4.8.1 of the script:

1. First note the wordpress user password of the WordPress database cat /root/wordpress_db_passwords.txt
2. Enter the jail iocage console wordpress and execute the following commands, substituting the wordpress user password for...
Read the rest of this update entry...
 

Basil Hendroff

Neophyte Sage
Joined
Jan 4, 2014
Messages
1,303
Basil Hendroff updated Scripted WordPress Installation with a new update entry:

Upgrade to MariaDB 10.4

MariaDB 10.4 uses an improved authentication model. Versions 1.x of the script used MariaDB 10.3. Assuming you've previously run version 1.5.0 of the installation script, you can upgrade to the newer version of MariaDB by performing the following steps within the WordPress jail:

It's recommended that you backup the MariaDB databases before proceeding. You can use phpMyAdmin to accomplish this. Once you've completed the backup, proceed with the following steps:

1. Stop MariaDB...
Read the rest of this update entry...
 

Basil Hendroff

Neophyte Sage
Joined
Jan 4, 2014
Messages
1,303
Basil Hendroff updated Scripted WordPress Installation with a new update entry:

Upgrade to MariaDB 10.5

After a somewhat bumpy ride upgrading from MariaDB 10.3 to 10.4, the upgrade from MariaDB 10.4 to 10.5 turned out to be painless. There are no outwardly visible changes arising from the upgrade. Assuming you've previously run version 2.0.0 of the installation script, you can upgrade to the newer version of MariaDB by performing the following steps within the WordPress jail:

It's recommended that you backup the MariaDB databases before proceeding. You can use phpMyAdmin to accomplish this...
Read the rest of this update entry...
 

Basil Hendroff

Neophyte Sage
Joined
Jan 4, 2014
Messages
1,303
Basil Hendroff updated Scripted WordPress Installation (for Reverse Proxy) with a new update entry:

Install WP-CLI for command-line support

Notable changes in this release:
  1. Install the command line tool WP-CLI within the jail.
  2. Bugfix: Avoid the use of $ when generating passwords.
  3. Bugfix: Authentication keys and salts on wp-config.php.
Acknowledgements: @NasKar for his valuable contributions to this release.

To update your wordpress jail you've run the previous version 2.1.0 of the script, enter the jail iocage console wordpress and then follow the...
Read the rest of this update entry...
 
Top