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

2 thoughts on “upgrading php on openbsd”

Leave a Reply

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