June 08, 2020
Trying to setting up PHP 5 on Raspberry Pi
Three years ago today.
The Sun-Pi has a twin, the Web-Pi, that will be used to do porting from the Sun-Dragon. One of my first tasks is to get a LAMP stack install on the Pi. However as I discovered sometime ago, PHP 7 deprecated all the old PHP functions I seem to use on just about every PHP website I host. Thus I need to run PHP 5 until I can either port or flatten the sites.
I did find a write up of how to run both PHP 5 and PHP 7, but the repositories are not available for ARM so they are of no use. My next option was simply to compile PHP 5 from source. I used to do this for part of the LAMP stack back in the day. I would regularly compile Apache, OpenSSL, and PHP periodically. I never updated the Linux kernel though and usually only ever updated the OS when the hardware changed.
What followed was a couple days of trial and error. Compiling PHP has always taken awhile. One must fetch all the prerequisite packages. The process involves trying to configure PHP, waiting for it to fail, then finding the next missing package, and trying again.
After everything looked correct the first problem I ran into was OpenSSL. Seems that after version 1.1 the API changed enough that PHP 5 would not compile. Since PHP 5 is no longer supported I would not be able to get anything official. My first through was to compile and use the older version of OpenSSL. This did allow PHP to compile, but PHP would segment fault Apache when trying to load. This is because the version of OpenSSL on the system didn’t match the one I compiled against. There may be a way to work around this, however, I don’t think I actually need OpenSSL in PHP and opted to compile PHP without it. That worked and I was able to verify the root site of DrQue.net was functional.
Tomorrow I will detail what it takes to compile PHP 5 on a Raspberry Pi.