Butterfly Builder. A PHP Built Tool written completely in BASH

Yoander Valdés Rodríguez 8e744fef9f Improve and refactor 1 year ago
extensions 8e744fef9f Improve and refactor 1 year ago
metalinks 9df19852d8 Add Ubuntu 18.04 config 2 years ago
post-install 8e744fef9f Improve and refactor 1 year ago
pre-build ada5aa3f71 Add GD dependencies for Ubuntu 2 years ago
signatures 27808164d8 Compile pcre2-10.33 for Debian 9 3 years ago
www 8df4c24461 Add builtin post install action 3 years ago
.gitignore d4f501c14f Ignore signatures DIR 2 years ago
LICENSE b675c58fba Initial commit 4 years ago
README.md fa6c216eff Add new Blogs and tutorials entry 2 years ago
build 8e744fef9f Improve and refactor 1 year ago
build.ini 8e744fef9f Improve and refactor 1 year ago
mirrors.txt 0ffc90eca9 Update mirrors template 4 years ago
sigd 3770874c92 Replace pbt references by build 2 years ago
template.metalink cf4cd95b78 Release candidate 4 years ago



Butterfly Builder is a tool written in BASH that allows to compile PHP from the source code, Butterfly Builder (before pbt) is the evolution of the php-build.sh script allowing greater flexibility and customization in the PHP compilation / installation process.


  • Use a configuration file (build.ini) instead of the command line options.

  • Download / uncompress the PHP version specified in the configuration file and start the compilation and installation process automatically.

  • Allows to enable / disable common extensions through the common.conf file that is included in the DIR extensions.

  • Allows to enable / disable specific extensions, using the build.ini configuration file and files related to the extension, found in the DIR extensions, example: mysql.conf.

  • Allows to enable extensions for a specific PHP version, for example the php-7.2.x.conf file that is located under the DIR extensions.

  • Allows to execute actions prior to the compilation process such as installing necessary dependencies. The previous actions are under pre-build DIR, example of previous actions: centos, centos-php-7.2.x.

  • Allows to execute actions after the installation process such as creating the PHP configuration file and creation of initialization scripts (systemd, sysv). The final actions are under post-install DIR.

  • Use curl as a download manager allowing to use metalinks as long as the metalink feature is available, otherwise curl will be used in its standard form, the script will iterate through each PHP mirror until it finds the first one that responds successfully to the download request.

  • Perform PHP integrity tests in case of failure the compilation process is aborted.

Directory structure


downloads: Cache of downloaded files if there was a partial or corrupt download should be cleaned.

extensions: Extensions configuration.

metalinks: The generated metalinks are saved, a metalink is generated for each version of PHP to be downloaded, the version is specified in the build.ini.

post-install: Post-installation actions, example activate opcache.

pre-build: Actions prior to the compilation process, example install dependencies.

signatures: Where digital signatures are stored, digital signatures must be downloaded manually from the PHP site or using sigd tool distributed in the root DIR, sigd takes as granted that your DNS is not poisoned.


build: Script that executes download / compilation / installation processes.

build.ini: Configuration file.

mirrors.txt: Mirror list of where PHP will be downloaded in case curl does not support metalinks.

template.metalink: Template to create the metalinks

sigd: Tool to download signatures from PHP site, use jq package for JSON parsing.

Configuration file

The configuration file build.ini allows to set parameters that will be used during the compilation process.

php_version: Set the version to download / compile.

compression: Sets the extension of the file to be downloaded.

php_mode: Sets the way PHP will run: fpm or mod_php

fpm_user: User under which the fpm service will be executed.

fpm_group: Group under which will execute the fpm service.

fpm_listen: Port in which the fpm service will be receiving connections.

fpm_allowed_clients: Allowed IPs (separated by,). Leave blank to allow access from any device.

web_server: It has the purpose of executing actions prior to compilation / post-installation, example to install the nginx server, see previous action: centos-nginx.

install_prefix: Directory where PHP will be installed.

sysinit: Specify how to create the initialization, sysv or systemd scripts.

sysinit_versioned: A value of "true" allows you to create versioned initialization scripts, example php72-fpm, allowing you to have installed / use more than one PHP version at the same time.

databases: Compiles PHP with the specific DB drivers also allows to execute actions prior/after to compilation process.

php_env: Create the php.ini according to the specified environment.

How to use

$ ./build

Tested OS

NO Platform PHPVersion
1 CentOS 7 7.2
2 Debian 8 7.3
3 Ubuntu 18.04 7.4

Blogs and tutorials