Repository navigation
fix: use DDEV's php.ini and .ddev/php settings, add common extensions - #16
Merged
Merged
Conversation
Static PHP looked for its configuration only in /usr/local/etc/php, which didn't exist, so neither the CLI nor php-fpm loaded any php.ini. DDEV's settings (memory_limit, upload limits, Mailpit's sendmail_path) and .ddev/php/*.ini overrides had no effect. - Link DDEV's cli and fpm php.ini as php-cli.ini and php-fpm-fcgi.ini, which static PHP reads before php.ini - Build with a scan dir that includes /mnt/ddev_config/php so .ddev/php overrides apply; DDEV's conf.d can't be used because static PHP can't load shared extensions, so carry over its zend.assertions setting - Point /etc/php-fpm.conf at the php_version directory - Download pre-built libraries where available, which roughly halved the build time on arm64 - Add mysqli, intl, zip, sodium, iconv, exif, xmlreader, xmlwriter, posix, pcntl and calendar to the default extensions - Document configuration, missing extensions and how to add extensions - Test ini loading and the new extensions for directory installs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Issue
PHP 8.5.12, 8.4.27, 8.3.36 and 8.2.35 fix the "PHP2Shell" vulnerabilities (DDEV blog post). deb.sury.org only has amd64 packages so far, so on arm64 this add-on is one way to get a patched PHP. Testing it with 8.5.12 on Apple Silicon turned up these problems:
/usr/local/etc/php, which didn't exist; the existing/etc/php.inisymlink was never read. The CLI and php-fpm both ran on PHP's built-in defaults:memory_limit128M,upload_max_filesize2M, andsendmail_pathnot pointing at Mailpit..ddev/php/*.inioverrides had no effect, including the blog post's mitigation settings.mysqli, which WordPress requires.How This PR Solves The Issue
php.iniinto/usr/local/etc/phpasphp-cli.iniandphp-fpm-fcgi.ini. PHP reads the SAPI-specific file beforephp.ini, so each SAPI gets DDEV's settings.--with-config-file-scan-dir=/usr/local/etc/php/conf.d:/mnt/ddev_config/phpso.ddev/php/*.inioverrides apply. DDEV's own conf.d can't be scanned because itsextension=lines make static PHP print warnings, so its one other setting,zend.assertions = 1, is written to/usr/local/etc/php/conf.d./etc/php-fpm.confat thephp_versiondirectory, where DDEV copies the overrides, instead of the static version's directory.--prefer-pre-built. The build took 13m54s, about 5 minutes of which was a mirror returning 504s, so roughly 9 minutes, while building 12 more extensions.mysqli,intl,zip,sodium,iconv,exif,xmlreader,xmlwriter,posix,pcntlandcalendarto the default extensions.uploadprogress,xmlrpc, Xdebug), with an example of adding extensions.php_versionis no longer described as ignored: it chooses the php.ini and php-fpm configuration, so it should match the built minor version.Tested by hand on arm64 (OrbStack, DDEV HEAD) with PHP 8.5.12:
.ddev/phpoverrides.php -mshows no warnings.mail()goes through Mailpit.Manual Testing Instructions
Add a
.ddev/php/test.inicontainingupload_max_filesize = 7M, runddev restart, and confirmini_get('upload_max_filesize')returns 7M from bothddev phpand a web page.Automated Testing Overview
A new
unreleased_checksfunction runs only in the "install from directory" test. It checks:memory_limit, a.ddev/phpoverride andzend.assertions, from both the CLI and php-fpmphp -mprints no warningsThe "install from release" test can't check these until they're released. After the next release, these checks can move into
health_checks.I didn't run the bats tests locally (my router uses a non-default port), so CI is the first run.
Release/Deployment Notes
memory_limitand upload limits change from PHP defaults to DDEV's.php_versiondiffers from the static version's minor will now get the php.ini and php-fpm configuration forphp_version.unreleased_checksintohealth_checks.🤖 Generated with Claude Code