Skip to content

Instantly share code, notes, and snippets.

@matasarei
Last active July 12, 2024 19:33
Show Gist options
  • Select an option

  • Save matasarei/cfc248684d04ce3d32eadcb90701ecbb to your computer and use it in GitHub Desktop.

Select an option

Save matasarei/cfc248684d04ce3d32eadcb90701ecbb to your computer and use it in GitHub Desktop.
Install PHP from sources
git clone https://github.com/php/php-src.git
cd php-src

./buildconf

./configure \
  --prefix=/opt/php/dev \
  --enable-cli \
  --enable-fpm \
  --enable-intl \
  --enable-opcache \
  --enable-sockets \
  --enable-soap \
  --enable-mbstring \
  --with-freetype \
  --with-ldap \
  --with-curl \
  --with-openssl \
  --with-fpm-user=www-data \
  --with-fpm-group=www-data \
  --with-jpeg \
  --with-mysql-sock \
  --with-mysqli \
  --with-pdo-mysql \
  --with-pgsql \
  --with-xsl \
  --with-zlib

make install

cp php.ini-production /opt/php/dev/lib/php.ini
mv /opt/php/dev/etc/php-fpm.d/www.conf.default /opt/php/dev/etc/php-fpm.d/www.conf
mv /opt/php/dev/etc/php-fpm.conf.default /opt/php/dev/etc/php-fpm.conf

Service example:

# /etc/systemd/system/php-fpm.service
[Unit]
Description=PHP FPM service
After=network.target

[Service]
PIDFile=%t/php-fpm.pid
ExecStartPre=/bin/mkdir --parents %t
ExecStart=/opt/php/sbin/php-fpm --fpm-config /opt/php/etc/php-fpm.conf --nodaemonize
ExecReload=/bin/kill -USR2 $MAINPID
Type=simple

[Install]
WantedBy=multi-user.target

After adding a service:

systemctl daemon-reload
systemctl start php-fpm
systemctl status php-fpm
git clone https://github.com/remicollet/php-src.git -b PHP-5.6-openssl11
cd php-src

wget https://ftp.gnu.org/gnu/bison/bison-2.7.tar.xz

tar -xvf bison-2.7.tar.xz;
cd bison-2.7/
chmod +x configure
mkdir build
./configure --prefix=$(pwd)/build
make -j $(nproc)
make install

./buildconf

PATH=$(pwd)/bison-2.7/build/bin:$PATH ./configure \
  --prefix=/opt/php/5.6 \
  --enable-mbstring \
  --enable-fpm \
  --with-curl \
  --with-openssl \
  --with-xmlrpc \
  --enable-soap \
  --enable-zip \
  --with-gd \
  --with-jpeg-dir \
  --with-png-dir \
  --with-mysql \
  --with-fpm-user=www-data \
  --with-fpm-group=www-data \
  --with-mysql-sock \
  --with-mysqli \
  --with-pdo-mysql \
  --with-pgsql \
  --enable-embedded-mysqli \
  --with-freetype-dir \
  --with-ldap \
  --enable-intl \
  --with-xsl

make install
cp php.ini-production /opt/php/5.6/lib/php.ini
mv /opt/php/5.6/etc/php-fpm.conf.default /opt/php/5.6/etc/php-fpm.conf
git clone https://github.com/remicollet/php-src.git -b PHP-7.0-openssl11
cd php-src

./buildconf

./configure \
  --prefix=/opt/php/7.0 \
  --enable-mbstring \
  --with-curl \
  --with-openssl \
  --enable-soap \
  --enable-zip \
  --with-gd \
  --with-jpeg-dir \
  --with-png-dir \
  --with-pgsql \
  --enable-embedded-mysqli \
  --with-freetype-dir \
  --with-ldap \
  --enable-intl \
  --with-xsl \
  --enable-cli \
  --enable-fpm \
  --enable-opcache \
  --enable-sockets \
  --enable-mbstring \
  --with-xmlrpc \
  --with-fpm-user=www-data \
  --with-fpm-group=www-data \
  --with-mysql-sock \
  --with-mysqli \
  --with-pdo-mysql \
  --with-zlib

make install
cp php.ini-production /opt/php/7.0/lib/php.ini
mv /opt/php/7.0/etc/php-fpm.d/www.conf.default /opt/php/7.0/etc/php-fpm.d/www.conf
mv /opt/php/7.0/etc/php-fpm.conf.default /opt/php/7.0/etc/php-fpm.conf
git clone https://github.com/php/php-src.git --branch=PHP-7.4
cd php-src

./buildconf

./configure \
  --prefix=/opt/php/7.4 \
  --enable-mbstring \
  --with-curl \
  --with-openssl \
  --enable-soap \
  --enable-zip \
  --with-gd \
  --with-jpeg-dir \
  --with-png-dir \
  --with-pgsql \
  --enable-embedded-mysqli \
  --with-freetype-dir \
  --with-ldap \
  --enable-intl \
  --with-xsl \
  --enable-cli \
  --enable-fpm \
  --enable-opcache \
  --enable-sockets \
  --enable-mbstring \
  --with-xmlrpc \
  --with-fpm-user=www-data \
  --with-fpm-group=www-data \
  --with-mysql-sock \
  --with-mysqli \
  --with-pdo-mysql \
  --with-zlib

make install

cp php.ini-production /opt/php/7.4/lib/php.ini
mv /opt/php/7.4/etc/php-fpm.d/www.conf.default /opt/php/7.4/etc/php-fpm.d/www.conf
mv /opt/php/7.4/etc/php-fpm.conf.default /opt/php/7.4/etc/php-fpm.conf
git clone https://github.com/php/php-src.git --branch=PHP-8.0
cd php-src

./buildconf

./configure \
  --prefix=/opt/php/8.0 \
  --enable-cli \
  --enable-fpm \
  --enable-intl \
  --enable-opcache \
  --enable-sockets \
  --enable-soap \
  --enable-mbstring \
  --with-freetype \
  --with-ldap \
  --with-curl \
  --with-openssl \
  --with-fpm-user=www-data \
  --with-fpm-group=www-data \
  --with-jpeg \
  --with-mysql-sock \
  --with-mysqli \
  --with-pdo-mysql \
  --with-pgsql \
  --with-xsl \
  --with-zlib

make install

cp php.ini-production /opt/php/8.0/lib/php.ini
mv /opt/php/8.0/etc/php-fpm.d/www.conf.default /opt/php/8.0/etc/php-fpm.d/www.conf
mv /opt/php/8.0/etc/php-fpm.conf.default /opt/php/8.0/etc/php-fpm.conf
git clone https://github.com/php/php-src.git --branch=PHP-8.1
cd php-src

./buildconf

./configure \
  --prefix=/opt/php/8.1 \
  --enable-cli \
  --enable-fpm \
  --enable-intl \
  --enable-opcache \
  --enable-sockets \
  --enable-soap \
  --enable-mbstring \
  --with-freetype \
  --with-ldap \
  --with-curl \
  --with-openssl \
  --with-fpm-user=www-data \
  --with-fpm-group=www-data \
  --with-jpeg \
  --with-mysql-sock \
  --with-mysqli \
  --with-pdo-mysql \
  --with-pgsql \
  --with-xsl \
  --with-zlib

make install

cp php.ini-production /opt/php/8.1/lib/php.ini
mv /opt/php/8.1/etc/php-fpm.d/www.conf.default /opt/php/8.1/etc/php-fpm.d/www.conf
mv /opt/php/8.1/etc/php-fpm.conf.default /opt/php/8.1/etc/php-fpm.conf
git clone https://github.com/php/php-src.git --branch=PHP-8.2
cd php-src

./buildconf

./configure \
  --prefix=/opt/php/8.2 \
  --enable-cli \
  --enable-fpm \
  --enable-intl \
  --enable-opcache \
  --enable-sockets \
  --enable-soap \
  --enable-mbstring \
  --with-freetype \
  --with-ldap \
  --with-curl \
  --with-openssl \
  --with-fpm-user=www-data \
  --with-fpm-group=www-data \
  --with-jpeg \
  --with-mysql-sock \
  --with-mysqli \
  --with-pdo-mysql \
  --with-pgsql \
  --with-xsl \
  --with-zlib

make install

cp php.ini-production /opt/php/8.2/lib/php.ini
mv /opt/php/8.2/etc/php-fpm.d/www.conf.default /opt/php/8.2/etc/php-fpm.d/www.conf
mv /opt/php/8.2/etc/php-fpm.conf.default /opt/php/8.2/etc/php-fpm.conf
git clone https://github.com/php/php-src.git --branch=PHP-8.3
cd php-src

./buildconf

./configure \
  --prefix=/opt/php/8.3 \
  --enable-cli \
  --enable-fpm \
  --enable-intl \
  --enable-opcache \
  --enable-sockets \
  --enable-soap \
  --enable-mbstring \
  --with-freetype \
  --with-ldap \
  --with-curl \
  --with-openssl \
  --with-fpm-user=www-data \
  --with-fpm-group=www-data \
  --with-jpeg \
  --with-mysql-sock \
  --with-mysqli \
  --with-pdo-mysql \
  --with-pgsql \
  --with-xsl \
  --with-zlib

make install

cp php.ini-production /opt/php/8.3/lib/php.ini
mv /opt/php/8.3/etc/php-fpm.d/www.conf.default /opt/php/8.3/etc/php-fpm.d/www.conf
mv /opt/php/8.3/etc/php-fpm.conf.default /opt/php/8.3/etc/php-fpm.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment