Skip to content

Instantly share code, notes, and snippets.

@olavocneto
Last active November 25, 2022 14:52
Show Gist options
  • Save olavocneto/3c9321c535210b12b297a9d25c91d65c to your computer and use it in GitHub Desktop.
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment