Skip to main content

Installing a custom version of PHP on Dreamhost

Dreamhost does not support php-fpm on it's VPS server so I put together q guide on how to get it to work if you ever need to. It seems to be a better way than the default CGI version.

Install dependencies first

Install all the libs php will need. They all need to be made and deployed. I like to add webp, zlib, and onigurma.

wget https://github.com/kkos/oniguruma/releases/download/v6.9.8/onig-6.9.8.tar.gz
tar -zxvf onig-6.9.8.tar.gz
./configure --prefix=$HOME/opt/onig
make
make install

wget https://github.com/webmproject/libwebp/archive/refs/heads/main.zip
unzip main.zip
./autogen.sh 2>/dev/null || true
./configure --prefix=$HOME/opt/libwebp

wget https://libzip.org/download/libzip-1.9.2.tar.gz
wget https://github.com/Kitware/CMake/releases/download/v3.28.3/cmake-3.28.3-linux-x86_64.tar.gz
cd libzip-1.9.2
mkdir build 
../../cmake-3.28.3-linux-x86_64/bin/cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/opt/libzip
make
make install

Add the new libs to your path for PHP

PHP will need to access these libs for some of the config features.

export PKG_CONFIG_PATH=$HOME/opt/onig/lib/pkgconfig:$HOME/opt/libzip/lib/pkgconfig:$HOME/opt/libwebp/lib/pkgconfig:$PKG_CONFIG_PATH
export LD_LIBRARY_PATH=$HOME/opt/onig/lib:$HOME/opt/libzip/lib:$HOME/opt/libwebp/lib:$LD_LIBRARY_PATH

Install php

Now we finally get to make PHP and install it. PHP does take some time tp make, about 10-15 minutes so don't be alarmed.

wget https://www.php.net/distributions/php-8.4.1.tar.gz
tar -zxvf php-8.4.1.tar.gz
./configure \
  --prefix=$HOME/opt/php8.4.1 \
  --enable-fpm \
  --with-zlib \
  --with-curl \
  --with-openssl \
  --with-pdo-mysql \
  --with-mysqli \
  --enable-mbstring \
  --enable-intl \
  --enable-simplexml \
  --enable-gd \
  --with-webp \
  --with-jpeg \
  --enable-opcache \
  --with-zip \
  --enable-pcntl
make
make install

Now you can go to your newly created php instance create a few settings files, and run the server. Use the nodemonize directive at first for debugging.

./php-fpm --nodaemonize

Install Pecl

Pecl helps you easily add additional extensions for PHP. Installing it only requires a few commands and it is well worth it for things like Redis or ACPu for example. Start from back in the source folder.

curl -O https://pear.php.net/go-pear.phar
../php8.4.1/bin/php go-pear.phar

This will lauch the installer. You will want to adjust a couple things here. Set prefix to be /home/user/opt/pear and the temporary folders to be /home/user/opt/src/tmp. Make sure to use your user account. When finished, include it in your path and you should be all set!

export PATH=$PATH:~/opt/php8.4.1/bin:~/opt/pear/bin
pecl install apcu
pecl install redis

To enable the extensions you will need to edit your php.ini file and add configuration lines like extension=apcu.so.

Restart PHP-FPM

Kill all php-fpm processes and then start it up again.

pkill -9 php-fpm
~/opt/php8.4.1/sbin/php-fpm

That's all!

Need help with your project or have questions?

We specialize in AI automation, custom integrations, and intelligent workflows tailored to your business needs.

Whether you need help deploying, building, implementing, or creating a solution - or just want expert guidance on your project - we're here to help.

Contact us today to discuss your project.