PHP – How to create a simple Debian/Ubuntu package for PHP

php linux photo

WARNING: This is probably not the right way to create a package for PHP. Do not use this in production for anything. This is just a test / intro into my package building capabilities! If you or anyone you know knows the correct way to package PHP please comment down below, otherwise I’ll never learn right

Photo by tacker


1. git clone https://github.com/php/php-src.git
2. mkdir /root/package-build/ && mv php-src /root/package-build/php-7.3.11
3. cd /root/package-build/php-7.3.11 && git checkout php-7.3.11
4. ./buildconf –force
5. dh_make –createorig
6. nano debian/rules

Append the following (these are our configure options)

override_dh_auto_configure:
        dh_auto_configure -- --prefix=/root/package-build/php-7.3.11/debian/php/opt/php73 --with-zlib-dir --with-freetype-dir --enable-mbstring --with-libxml-dir=/root/package-build/php-7.3.11/debian/php/usr --enable-soap --enable-calendar --with-curl --with-gd --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --enable-exif --enable-bcmath --with-mhash --enable-zip --with-pcre-regex --with-pdo-mysql --with-mysqli --with-jpeg-dir=/root/package-build/php-7.3.11/debian/php/usr --with-png-dir=/root/package-build/php-7.3.11/debian/php/usr --with-openssl --with-fpm-user=www-data --with-fpm-group=www-data --with-libdir=/lib/x86_64-linux-gnu --enable-ftp --with-kerberos --with-gettext --with-xmlrpc --with-xsl --enable-opcache --enable-fpm --with-imap-ssl --with-imap --enable-intl

IMPORTANT NOTE: make sure the spacing before “dh_auto_configure” is exactly one tab, spaces DO NOT WORK.
7. debuild

Bam! That’s it. In /root/package-build you should now have an assembled PHP package that installs to /opt/php73.

You May Also Like

Leave a Reply

Your email address will not be published. Required fields are marked *