If you work with Nginx and you want to override your PHP settings from an external file that won't get deleted or changed in updates, you can create a /etc/php/*/fpm/zz_overrides.ini
and put your PHP env changes there.
When I worked with Nginx, I configured zz_overrides.ini
in my environment by running this script:
#!/bin/bash
for dir in /etc/php/*/fpm/; do
cat <<-"EOF" > "$dir"/zz_overrides.ini
[PHP]
post_max_size = 2000M
upload_max_filesize = 2000M
max_execution_time = 3000
EOF
done
ln -s /etc/php/*/fpm/zz_overrides.ini /etc/php/*/fpm/conf.d/20-zz-overrides.ini
# Enable the above php.ini extension via a symlink in conf.d;
Now I went back working with Apache (in which I never did that task and I believe it should be quite different there due to lack of php-fpm utilization, naturally).
How should I do similar overriding in Apache?
Newcomers: Note that changing PHP.ini itself isn't effective as it will be re-written in each upgrade).
In Apache you could can use
php_flag
directives inside a virtualhost configuration (or a.htaccess
file inside the document root dir).The following example mimics your current script, by creating a
./conf-available/$vhost/php_overrides.conf
with php override directives per enabled virtualhost and inserts (or updates) anInclude
directive pointing to that file (paths are Debian style, adapt to your needs):However, since it seems all your virtual hosts use the same PHP overrides, it would be easier just to create a file
./conf-available/php_overrides.conf
once, include the following line in each vhost configuration, and then create or remove symlinks in./conf-enabled
to control if it will be used:So to use it:
To stop using it: