php_build_ubuntu.sh
Automates building and installing PHP 8.x from source for testing on Ubuntu flavors with optional MySQL/MariaDB support and Apache integration.
This script compiles PHP 8.x by version choice from source, installs common extensions (mbstring, GD, curl, LDAP, etc.), and sets up MySQL or MariaDB support. It also configures Apache integration and handles alternative PHP paths.
Built and maintained by Maulik Mistry (m1st0) (original Gist)
- Compile PHP 8 from source with popular extensions
- Auto-detect MySQL vs. MariaDB
- Apache module configuration and update-alternatives
- Error-handling and environment setup
- Color-coded script output for clarity
- Clone the repo:
git clone https://github.com/yourusername/php-build-ubuntu.git
cd php-build-ubuntu- Make executable:
chmod +x php_build_ubuntu.sh- Run (may require sudo):
sudo ./php_build_ubuntu.sh- Follow the prompts to select PHP version (default is 8.4.9) and confirm compilation options.
- You may change the default version by obtaining tags from the php-src repository or by checking out a version tag inside the
php-srcfolder that the script creates on first run, and updating thePHP_VERSIONvariable accordingly.
This project is licensed under the BSD-2-Clause license.
See LICENSE.txt for full details.
If you find this script helpful, consider supporting me:
Lets keep each other going, safe, and well.