upgrading php on openbsd

First take a snapshot or backup of your server.

Then, we’ll take a backup of our php-fpm.conf file
because if we uninstall php-7.3 it will remove this file too.
doas cp php-fpm.conf php-fpm.conf.bak

Now, let’s stop our instance of php-7.3
doas rcctl stop php-7.3

install php-curl which will pull in php as well.
doas pkg_add -iv php-curl

When presented with a list of php-versions pick php-7.4

Also, install php-zip and pecl74-imagick.
doas pkg_add -iv php-gd php-zip pecl74-imagick

Remember, none of these modules are activated by default by OpenBSD.
In order to activate them, we need to copy them from /etc/php-7.4.sample
directory to /etc/php-7.4

cd /etc/php-.7.4
doas cp ../php-7.4.sample/* .

Now with our files in place and php upgraded, lets edit our
/etc/rc.conf.local file and change php73_fpm to php74_fpm

And we can now start up php74_fpm
doas rcctl start php74_fpm

Refresh our website and make sure WordPress is running fine.

Now we can delete php-7.3
doas pkg_delete -iv php-7.3

This will also remove php-fpm.conf and our site will be broken.
Fortunately we made a backup of this file.
doas mv /etc/php-fpm.conf.bak /etc/php-fpm.conf

Do some file cleanup
doas rm -r /etc/php-7.3 /usr/local/share/php-7.3

doas on openbsd

doas, available on OpenBSD as part of the default system, is a simpler replacement for sudo.

Become root user and then copy doas configuration file from /etc/examples/.

su -

cp /etc/examples/doas.conf /etc/

Use your favorite editor or vi or Emacs clone mg which are included in the base to edit /etc/doas.conf. Add the word “persist” after “permit” to enter your password less often.

Adding unicode characters to python repl

One way to add a Unicode character to Python’s REPL is to add it as a string literal.

Suppose you had the phrase “My Spanish brown eyed girl.”

To print the phrase with a Jerusalem cross between each word you would find on the internet a Unicode character reference that gives you the number sequence in this case, U+2629.

Since join method accepts one argument lets first place our sentence in a variable.

my_girl = 'My', 'Spanish', 'brown', 'eyed', 'girl.'

print('\u2629'.join('My Spanish brown eyed girl.'))

This will output the following:

My☩Spanish☩brown☩eyed☩girl.

Upgrading WordPress on OpenBSD and httpd

When I first setup WordPress on OpenBSD I followed Michael W. Lucas’s book, “Httpd and Relayd”. Actually, this was my first experience ever setting up WordPress on any server. The steps Michael gave made setting it up straightforward. But, when there was an update to WordPress 5.3 yesterday, I felt a bit nervous. I couldn’t find a howto or tutorial on how to upgrade WordPress in a chroot.

httpd on OpenBSD runs in a chroot. I thought this would prove to be a huge problem but it wasn’t too difficult to update.

In addition to Michael’s book mentioned above, the WordPress documentation on doing a manual upgrade was also helpful.

https://wordpress.org/support/article/updating-wordpress/#manual-update

I adapted the above instructions from WordPress’s to the fact that WordPress runs in a chroot on OpenBSD.

To begin with, I downloaded the latest updated stable code from WordPess.

ftp https://wordpress.org/latest.tar.gz

Unpack the gzipped tarball and remove the old wp-includes and wp-admin directories
tar -xzf latest.tar.gz
doas rm -r /var/www/htdocs/wp-includes/ /var/www/htdocs/wp-admin/
Now, update all the files without removing your own content.
doas rsync --update -ra --progress wordpress/ /var/www/htdocs/

All of our fresh files from WordPress are in place. Let’s fix the permissions on those files.

doas chown -R www:www /var/www/htdocs

That’s all I needed to do. I have a simple setup. Your mileage may vary.

Changing username on centos linux

Let’s say I have the username of tom and my main group is also tom.

For some reason I now need my username to be jerry and in the group jerry.

sudo usermod -l jerry tom

That changed the username from tom to jerry. But jerry is still in the group tom.

sudo groupmod -n jerry tom

Okay. Now jerry is in the group jerry. But all jerry’s files are still in /home/tom.

sudo usermod -m -d /home/jerry jerry

Voila! Now tom is jerry.

make an ntfs formatted usb drive with a label

For some reason, I found it difficult to find the answer as to how I could take an USB thumb drive, format it with the NTFS file system, and label it. All from the command line and on Linux. After Googling, Duck Duck Go-ing it, and searching with Qwant I remembered that I have a handy little program installed called tldr.

tldr mkfs.ntfs

One of the results was the following:

  • Create filesystem with a volume-label: mkfs.ntfs -L {{volume_label}} {{/dev/sdb1}}

So first of all I needed to find the right device name for the thumb drive I had plugged in so I didn’t overwrite my 200 gigabyte home folder!

lsblk:
sdc               8:32   1   7.6G  0 disk  
└─sdc1            8:33   1   7.6G  0 part

Now that I had the right device to write to, I could create a file system on it.

sudo mkfs.ntfs /dev/sdc1 -L "THE WALKING DEAD"

Bingo! That did the trick.