Skip to content

Instantly share code, notes, and snippets.

@olavocneto
Last active March 17, 2026 13:16
Show Gist options
  • Select an option

  • Save olavocneto/3c9321c535210b12b297a9d25c91d65c to your computer and use it in GitHub Desktop.

Select an option

Save olavocneto/3c9321c535210b12b297a9d25c91d65c to your computer and use it in GitHub Desktop.
# Compiling PHP from source

# https://github.com/docker-library/php/blob/3dc9a6988d478fae0f0b8b871d10e611b50e3d0c/7.4/buster/cli/Dockerfile
# https://php.watch/articles/compile-php-ubuntu

sudo apt-get install make clang build-essential autoconf libtool bison re2c

# SQL Server for unixODBC development headers
sudo apt-get install unixodbc-dev

# ubuntu 18
sudo apt-get install libxml2-dev libxslt1-dev libssl-dev libsqlite3-dev libffi-dev libonig-dev libc-client-dev libsodium-dev libbz2-dev libcurl4-openssl-dev libpng-dev libjpeg-dev libfreetype6-dev libzip-dev libjpeg62-dev libjpeg8-dev libcurl4-nss-dev

# ubuntu 22.04
sudo apt-get install libxml2-dev libxslt1-dev libssl-dev libsqlite3-dev libffi-dev libonig-dev libc-client-dev libsodium-dev libbz2-dev libpng-dev libjpeg-dev libfreetype6-dev libzip-dev libjpeg62-dev libjpeg8-dev libmemcached-dev libsystemd-dev

# https://github.com/asdf-community/asdf-php/blob/master/.github/workflows/workflow.yml#L30
sudo apt-get install -y autoconf bison build-essential curl gettext git libgd-dev libcurl4-openssl-dev libedit-dev libicu-dev libjpeg-dev libmysqlclient-dev libonig-dev libpng-dev libpq-dev libreadline-dev libsqlite3-dev libssl-dev libxml2-dev libzip-dev openssl pkg-config re2c zlib1g-dev libmemcached-dev


---------------

./buildconf

./configure --with-apxs2=/usr/bin/apxs --with-zlib-dir --with-freetype --enable-mbstring --enable-soap --enable-calendar --with-curl --with-zlib --enable-gd --disable-rpath --enable-inline-optimization --with-bz2 --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --enable-exif --enable-bcmath --with-mhash --with-pdo-mysql --with-mysqli --with-mysql-sock=/var/run/mysqld/mysqld.sock --with-jpeg --with-openssl --with-fpm-user=www-data --with-fpm-group=www-data --with-libdir=/lib/x86_64-linux-gnu --enable-ftp --with-gettext --with-xmlrpc --with-xsl --enable-opcache --enable-intl --with-pear --enable-fpm --with-zip --with-sodium --with-ffi --enable-maintainer-zts --with-fpm-systemd CC=clang CFLAGS="-O3 -march=native"
# Or
./config.nice

make -j$(nproc)
make test
sudo make install

---------------

# Notes
PHP 7.4 (and PHP 8.0) are not compatible with OpenSSL 3. Either use PHP 8.1, or stick with OpenSSL 1.1 with these older PHP versions.
# Listar todos os pacotes PHP instalados atualmente
dpkg -l | grep -E "^ii\s+php" | awk '{print $2}'

# Alterar versão
sudo update-alternatives
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment