Fixing “Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib\n Referenced from: /usr/local/opt/php@7.0/lib/httpd/modules/libphp7.so\n Reason: image not found” after a php Update on a Mac

A few weeks ago, I discovered the WordPress “Site Health Status” tool. I saw that it recommended upgrading my outdated version of php so, being a good “computer guy”, I went ahead and did the upgrade. After the update, I found that I could not view my website. After digging around to remind myself about the

sudo apachectl -k restart

command, I got the error message

httpd: Syntax error on line 183 of /usr/local/etc/httpd/httpd.conf: Cannot load /usr/local/opt/php@7.0/lib/httpd/modules/libphp7.so into server: dlopen(/usr/local/opt/php@7.0/lib/httpd/modules/libphp7.so, 10): Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib\n  Referenced from: /usr/local/opt/php@7.0/lib/httpd/modules/libphp7.so\n  Reason: image not found

Since I use the Homebrew package manager, I followed the advice to do a

brew upgrade
brew cleanup

However, even after doing this, I found I still had the problem. Trying other advice, I tried reinstalling php, and saw advice that filled in the details specific to my computer’s environment from this documentation from the Homebrew Formulae page on php:

To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php7_module $(brew –prefix)/opt/php/lib/httpd/modules/libphp7.so

 <FilesMatch \.php$>
 SetHandler application/x-httpd-php
 </FilesMatch>

Finally, check DirectoryIndex includes index.php
DirectoryIndex index.php index.html

The php.ini and php-fpm.ini file can be found in:
$(brew –prefix)/etc/php/7.4/

This solved the problem! One catch: I had to edit the correct copy of the httpd.conf file. Unfortunately, I wasted several hours repeating the process a few times, editing a copy of the file in a place other than the path indicated right within the error message!

I am glad to have this problem fixed and the site up and running again. Now to get back to my next hobby programming project, which I hope I might publish soon….

Fixing ERR_CONNECTION_REFUSED errors attempting to connect to this site after changes

After upgrading(?) my Mac to MacOS Mojave, I found the hard disk access speed intolerable. Boot ups would take several minutes, and everything took far too long. I finally switched my Mac to boot up off of an external USB Solid State Drive (SSD). After cloning my hard drive to the SSD and switching it to be the default boot drive, the old(ish) Mac is once again pleasantly fast and usable.

However, after this change, I found that, whenever I attempted to connect to this site, any browser I tried to connect to it through would give a message about being unable to connect to the server. One specific message shown in Google Chrome was

ERR_CONNECTION_REFUSED

The first part of the solution came from a Stack Overflow answer by adang. In a terminal, I ran

sudo vi /etc/apache2/httpd.conf

I then uncommented the following lines by removing the pound (“#”) at the start of the line containing them:

LoadModule authz_core_module libexec/apache2/mod_authz_core.so
LoadModule authz_host_module libexec/apache2/mod_authz_host.so
LoadModule userdir_module libexec/apache2/mod_userdir.so
LoadModule include_module libexec/apache2/mod_include.so
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
LoadModule php7_module libexec/apache2/libphp7.so

Continuing with the instructions in the solution, I ran the following two commands:

sudo apachectl restart
apachectl configtest

The configtest revealed that apache was unable to find the specified SSL certificate file. As I compared the finder contents for the new SSD and the original hard drive, at first I thought that the certificate file had not copied over. So, I attempted to copy it from the hard drive to the SSD. However, as I tried to navigate through the folders on both drives, I found that the problem wasn’t that the file had not been copied during the cloning process, it was that I was unable to even see the contents of the folder containing the certificate files due to permissions. I needed to add read and execute rights to the folder as follows:

sudo chmod 755 /etc/letsencrypt/archive/

Once I did this, I was able to

sudo ls /etc/letsencrypt/archive/[domain-name]

and confirm that all files required were, in fact, there. Repeating the two apachectl commands this time resulted in the results being OK.

After doing this, I found that I needed to renew my letsencrypt SSL certificate.

certbot --version

showed that I was running an outdated version of certbot. I ran the following commands to update certbot, renew the certificate, and confirm that it had been updated.

brew update
brew upgrade certbot
sudo certbot certonly -w /path/to/website/ -d [domain-name] --preferred-challenges http

(I chose option 1, apache plug-in, when asked.)

sudo certbot renew --dry-run

After all this, the site is as good as new. I hope my directing people to the original solution for the main problem, and my steps for updating the SSL certificate, may be helpful to others.

Switch from Linux to MacOS

After many years of running on a series of old computers converted to Linux boxes and after a long downtime after the last one, a 2008 Dell notebook, died, this site is once again up, now running on MacOS. Sadly, I had foolishly set up the script to create database backups nightly so that it only wrote to a single file, overwriting it every night. The last time the job ran, it wrote only a small fraction of what it needed to do to create a full restoration script. I had to rely on a very old backup of a backup script from two years ago, thus losing my most recent posts and theme updates. I am still in the process of restoring this site, and have added a few different photos to use as header images with the “Radiate” theme. I hope to be a little more active posting things to this site as I continue working to restore it and get it up and running properly.