WordPress migration notes, part 3

Joy. Not.

I get to do a migration from my existing website to a new instance of WordPress on a new (virtual) machine.

This is the website I maintain as a volunteer service for a fellowship I am a part of. I’m the web servant, and have been since 2017. I originally inherited the static HTML website from a gentleman who wrote it in Microsoft FrontPage 98. But a few months later, a member showed me an app that helps our members find meetings. That app was written by a member, and is easiest to implement as a WordPress plugin. “I guess I’m learning WordPress now” was my 2017 motto.

Indeed, I wrote a whole new website using WordPress and incorporated the meeting finder plugin. I’ve been maintaining the website ever since. Five months ago, I migrated it from Bitnami on Amazon Lightsail, to straight Debian on Linode. For five months, it ran fine, mostly. Twice in the five months, MariaDB crashed due to an out-of-memory error.

Today, it cannot get but a few hours before MariaDB crashes due to an out-of-memory error. Something changed, but I don’t know what.

So I have created a new Debian virtual machine on Linode, and am installing WordPress on it. What follows are a few notes about the process.

I spun up a shared hosting Linode on the Nanode 1 GB plan. I should mention that this website doesn’t get but a thousand or two hits per month, and we recently had to cut our office manager’s pay 20% because inflation is hurting everyone and donations are down. More than $7 per month would be wasteful, and us not being good stewards of our member’s money.

So, Debian is installed, and I ran updates, and it is time to start configuring the new server. I’m still using only the IP address to get to the new machine, and will have to configure Let’s Encrypt / Certbot later.

First things first:

Vim was preinstalled, which was nice. That left picking my default editor:

update-alternatives --config editor

Next, I want to customize my bash shell:

vim ~/.bashrc

I commented in the aliases for ll and l and the export command for ls to use --color=auto

Then I added at the end:

alias ..='cd ..'
PS1="\[\033[0;32m\]\u\[\033[0;37m\]@\[\033[0;35m\]\h \[\033[0;34m\]\W\[\033[0;31m\]\$\[\033[0m\] "

Next, I set the host name:

hostnamectl set-hostname www.example.org

I think I rebooted, and then got back in.

apt install apache2 -y
systemctl status apache2
apt-get install php8.2 php8.2-cli php8.2-common php8.2-xml php8.2-mysqli php8.2-zip php8.2-curl libapache2-mod-php -y

This is similar to what is being described at Rose Hosting, but with a few changes.

I’m leaving out php8.2-imap, php8.2-redis, php8.2-snmp, and php8.2-mbstring. I know that I don’t have a need to do IMAP to a mailbox, because this small 1 GB1 RAM machine won’t be hosting a mail server. With “only” 1 GB of RAM, I need run as little excess code as possible. Likewise, I’m leaving out Redis because it really expects a minimum of 8 GB of RAM. I’m not planning on exposing SNMP to the outside world, so that can go. And I don’t see that I’ll ever need multibyte strings, so php8.2-mbstring is out.

Next is the database:

apt install mariadb-server -y
mysql_secure_installation
mariadb
systemctl enable mariadb

When I logged in to MariaDB, I did the Step 5. Create a WordPress database and user from the Rose Hosting page.

However, I used the same user name and password as on the old website. This is because I want to use the same wp-config.php from the old server. This has complications later.

Because of the low RAM situation and Automattic’s getting wasteful with other people’s money, instead of wget https://wordpress.org/latest.zip I brought in wordpress-6.5.5.tar.gz

Although I did this, Automattic is arrogant enough to know better than me, and upgraded me to the latest version anyway. I had to downgrade, manually. I would later have to add a plugin to prevent WordPress from upgrading itself.

WordPress was extremely grumpy and would not let me get to the administration pages to run the update permalinks action.

And at some point, WordPress got all messed up. It was a similar problem as talked about here, but it didn’t have the Bitnami components to it; only the wp-config.php. Since I brought in that file from the old server, I didn’t have to edit it, but now two records inside the database don’t match the configuration.

I was also trying to bring in the Apache configuration files from the old server. I don’t recall if I fixed Apache first, or WordPress first.

Since I had brought in the Apache configuration files from the old server, there were directives in the configuration files which needed to be met. This meant running the following, because Apache wouldn’t load without them:

a2enmod rewrite
a2enmod ssl

I did bring the configuration files in, but now Apache is grumpy about the missing SSL configuration. I needed to copy in the files from the Let’s Encrypt install.

If I recall correctly, this got Apache running, but WordPress was pretty messed up because it thought the root of the website was under /wordpress/ instead of under the base directory of /

There were two things I needed to do. One was to edit .htaccess in the WordPress directory:

RewriteBase /
RewriteRule . /index.php [L]

Both of these previously referred to /wordpress/ instead of /

The other thing I needed to do was to log in to MariaDB and run:

UPDATE wp_options SET option_value = REPLACE(option_value, 'http://172.16.1.1/wordpress', 'http://172.16.1.1/') WHERE option_name = 'siteurl';

UPDATE wp_options SET option_value = REPLACE(option_value, 'http://172.16.1.1/wordpress', 'http://172.16.1.1/') WHERE option_name = 'home';

Where 172.16.1.1 is a placeholder for the actual IP address of the running server.

And finally, I have a base WordPress install with the default theme, and the same admin password and path as the old server.

Now to migrate the old content over. I need to remind myself that I “get” to do this. Serenity Now! Serenity Now! Serenity Now!!!

  1. It amuses me to put the word “small” next to the phrase “1 GB RAM”. The first computer I ever programmed (in 1979) was a mini-mainframe with 4 KB of RAM. ↩︎

Migrated from OpenSuSE to Debian on my main machine today

This morning, I hadn’t planned on that, but….

I had a need to edit a PDF. I know that Firefox has the ability to do so; and I filled in information. But then it asked for a signature and initials – I have those in .jpeg form, but Firefox didn’t have the buttons for inserting images. Whoops: Firefox ESR version 115 doesn’t have that, because that showed up in Firefox 119.

Well, it has been a while since Tumbleweed was disappointing because of a lack of KWin tiling script support. I had downgraded from Tumbleweed to Leap 15.6. Maybe I should try Tumbleweed again.

Also, I’d been listening to the FLOSS Weekly podcast over on Hackaday, and their guest Brodie Robertson had mentioned Tumbleweed Slowroll as something new. I kind of liked the idea, so I tried a few steps.

These are list here, at the official page:

 zypper ar https://download.opensuse.org/slowroll/repo/oss/ temp
zypper in openSUSE-repos-Slowroll -openSUSE-repos-Tumbleweed
rm /etc/zypp/repos.d/*.repo # or backup
zypper dup

This got me an empty screen with a blinking cursor. Yay. Not.

I downloaded the Slowroll ISO and put it on a USB stick.

I used the BIOS to choose the USB stick to boot off of, and got the “Install” option. Sure, that can be a little drastic, but I’ve done this many times before. Mostly, it is a little annoying to find that I don’t have an application installed that I’d like to use at the moment. But because my /home is physically on a different drive, I’m safe to not lose any data (reasonable precautions taken).

I go to install Slowroll, and it reboots before starting the installation. The motherboard logo briefly shows, and then I’m back at the “Install” menu item again.

I’ve got a boot loop.

Great. Just great.

Did I mention that I dearly love systemd and journalctl (not). Back in the good old days, something would append to /var/log/messages, and I’d have a chance to figure out what went wrong. But with systemd, the journal is new every boot, and although I can successfully boot to a previous read-only snapshot, there’s nothing there from an aborted installation. Nothing at all. There’s only the current boot messages (which being from a successful snapshot tell me nothing).

Okay, maybe there’s something wrong on my boot drive. Physically disconnect the /home disk drive, boot off of a gparted ISO, and delete every partition on the boot / OS drive.

Try the Slowroll ISO USB again.

I’ve still got a boot loop.

Just great.

I’ve been building some Debian machines, as servers, so I can practice WordPress migrations. I pop in that USB stick, and Debian installs fine.

I still have to wrangle bringing in my /home disk drive and mounting it as /home, but at least it will work.

And here we are, a few hours later, on Debian with KDE. Thunderbird looks pretty different.

It was a little disconcerting that KDE > System Settings > Display and Monitor > Display Configuration > Scale works on each display independently of each other. OpenSuSE applied the scale to both screens simultaneously. I can see why it could make sense that one monitor (say a 4K monitor) might have a different scale factor than another way smaller one. But it was unexpected, so disconcerting. It can be really hard for me to read the screen when the screen is at 100% scale on both large monitors.

It is mildly amusing to me that I get to do How to make Ubuntu have a nice bash shell like OpenSuSE all over again, but for my main machine this time.

New Debian install; ssh and sudo changes

Similar to what I wrote in New OpenSuSE Tumbleweed cannot ssh in but this time with Debian. This has to be done from a physical console login on the machine (or if it was a VM, from the hosting company’s console login desktop service). I’m logged in as root.

apt-get install vim

Debian is pretty bare-metal, man. This is probably good from a security and stability point-of-view.

cd /etc/ssh/
cd /etc/ssh/

Find PermitRootLogin and uncomment it, and change it to yes

Find #PubkeyAuthentication yes and uncomment it.

Find #AuthorizedKeysFile     .ssh/authorized_keys .ssh/authorized_keys2 and uncomment it and remove the second file authorized_keys2

Find PasswordAuthentication no and uncomment it and change it to yesnote that this is temporary!

Save and exit the sshd_config file. I’m not sure which service(s) would need to be restarted here, so I issue the reboot now command and watch the machine reboot. Today’s hardware is amazingly fast, compared to what we lived with a decade ago.

Now, from my remote machine, I ssh in as root. I get asked about accepting the private key, and get prompted for the password. Once I get in, I know I’m good to proceed to the next step.

ssh-copy-id root@host.domain

I get asked to put in my password again, and now public key logins are enabled, instead of password-based logins.

I log in as root again, but this time without a password. At this point, I do some customizations per How to make Ubuntu have a nice bash shell like OpenSuSE (although this is Debian). One nice thing is that ~/.bashrc already had aliases ready for ll being an alias for ls -l

Something I don’t understand is why I cannot copy / paste from the Debian ssh session. My guess is that is has something to do with LS_OPTIONS in the bashrc file. Anyway….

I still needed to add alias ..='cd ..' though.

I log out.

I log in as a non-root user, with a password.

ssh-copy-id user@host.domain

I log in as the non-root user, without a password. Same thing: I add the customizations I like, where I can edit with vim, from doing a less on a file, the .. alias for changing directory up one, and using PageUp to search history. I log out.

I log in as root again. Now, I need to give my non-root user sudo rights.

adduser whatever-the-non-root-user-is sudo

Back to editing /etc/ssh/sshd_config

Find PermitRootLogin and uncomment it, and change it to no

Find PasswordAuthentication yes and uncomment it and change it to no

And then I save and exit the file and reboot the box.

Now I can ssh as the non-root user, and I cannot log in via ssh as root. Also, no-one can attempt to log in with just a password. This is good.