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.
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.
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.
# Uncomment only if /etc/os-release file does no exists # os_id=fedora # os_version=26 php_version=7.3.6 compression=tar.xz # fpm|mod_php php_mode=fpm fpm_user=phpfpm fpm_group=phpfpm # [IP:]PORT fpm_listen=9000 # IPs separated by , fpm_allowed_clients= # Allow to execute pre-build or post-install actions, vallue: apache-prefork|apache-worker|nginx|builtin or leave empty if the webserver # is installed or you want to install and configure the webserver by # yourself web_server= install_prefix=/usr/ # Non thread safe (nts)|Thread safe. Reserved for future use # thread_model=nts # sysv|systemd sysinit=systemd # This allows to create multiple init script for multiple php installation # a value of true creates versioned sysinit script for example php72-fpm # systemd unit sysinit_versioned=true # Allow to enable DB extension also to execute DB pre-build or post-install actions, value: mysql sqlite postgrep databases="mysql sqlite postgre" # dev|prod php_env=dev
How to use
To use Butterfly Builder download the compacted from NotABug or clone the repo, then give execution permissions to the build file (chmod a+x build) set the build.ini options according your needs and type
The download / compilation / installation process will begin immediately, Butterfly Builder has been tested on CentOS, Debian and Ubuntu.