Enabling APCu on DreamHost Servers with PHP 8

The Dreamhost logo.
The Cozy Nerd | May 17, 2022 Technology

Now that PHP7.4 is coming to an EOL (End of Life) at the end of this year, many are upgrading to PHP8. I needed to do this for not only this site, but some other projects that were still running on PHP7.4. Thankfully, DreamHost made the upgrade process from PHP7.4 to PHP8 very easy, with a simple click and select in their control panel. However, I did notice that there was a very useful PHP extension that wasn't enabled, or even available: the APCu module.

DreamHost doesn't really allow installing things via apt-get, or even having the PECL (another PHP method of installing extensions), so I had to look for another way to install the extension. Thankfully, I was able to find the instructions and after some testing, these instructions worked perfectly, and even have the module working for PHP8!

If you are here looking for something similar, here are the steps I did to get this to work (Note: This was on a DreamHost server, so if you have a different host, your milage may vary):

# SSH on to your server
$ cd ~
$ wget https://pecl.php.net/get/apcu-5.1.21.tgz
$ tar xvf apcu-5.1.21.tgz
$ mkdir .php/extensions
$ mv apcu-5.1.21 .php/extensions/apcu
$ cd .php/extensions/apcu
$ /usr/local/php80/bin/phpize
$ ./configure --with-php-config=/usr/local/php80/bin/php-config; make
$ cp ~/.php/extensions/apcu/modules/apcu.so $HOME
$ cd ~/.php/8.0
$ nano phprc
# Add the following line to phprc:

If you find this helpful, or if you find a much easier method of enabling the APCu PHP module for DreamHost, leave a comment below.