description: "A quick guide on how to compile PHP (especially new beta versions before packaging) to be able to test software with it"
aliases:
- /books/compiling-php-for-development
---
<!--more-->
## Preparation
This guide assumes that you will download the source to `~/php/source` and install PHP to `~/php/php8`. It should also work on all Linux/MacOS system assuming you have the right dependencies installed.
If you are using Debian/Ubuntu, you need to have the build-essentials installed.
This assumes you are going to run PHP as your user (instead of `www-data` or similar as normaly in production).
Create a new file called `build.sh` inside the source directory with the following content:
```bash
#!/bin/bash
set -e
set -x
INSTALL_DIR=/home/lukas/php/php8
USER=$(whoami)
mkdir -p $INSTALL_DIR
./configure --prefix=$INSTALL_DIR \
--enable-bcmath \
--enable-fpm \
--with-fpm-user="$USER" \
--with-fpm-group="$USER" \
--disable-cgi \
--enable-mbstring \
--enable-shmop \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--with-zlib \
--with-curl \
--without-pear \
--with-openssl \
--enable-pcntl \
--with-password-argon2 \
--with-sodium \
--with-zip \
--enable-mysqlnd \
--with-pdo-mysql \
--with-pdo-mysql=mysqlnd \
--enable-gd \
--with-freetype \
--enable-opcache
```
This should enable all PHP modules [Matomo](https://matomo.org/) needs to run. If you need more, adjust the lines above (and don't forget to end them with a `\`)