Customize the PHP configuration
Restart PHP after customizing
After making configuration changes, restart the PHP version’s PHP-FPM service.
sudo service php8.4-fpm-sp restart
sudo service php8.3-fpm-sp restart
sudo service php8.2-fpm-sp restart
sudo service php8.1-fpm-sp restart
sudo service php8.0-fpm-sp restart
sudo service php7.4-fpm-sp restart
sudo service php7.3-fpm-sp restart
sudo service php7.2-fpm-sp restart
sudo service php7.1-fpm-sp restart
sudo service php7.0-fpm-sp restart
sudo service php5.6-fpm-sp restart
Global vs. app customizations
Global customizations affect all apps on a server. App customizations affect only the app that was customized.
App customizations
An app’s PHP settings can be changed by customizing the app’s PHP-FPM pool configuration.
Add config files to an app’s FPM pool
When needing to customize an app’s PHP-FPM pool, adding a new configuration file is simpler than customizing the existing configuration files.
Add the new configuration file at the following location.
Replace APPNAME
with the name of the app.
Replace CUSTOM_FILE
with the name of a file that
does not already exist in the directory.
/etc/php8.4-sp/fpm-pools.d/APPNAME.d/CUSTOM_FILE.conf
/etc/php8.3-sp/fpm-pools.d/APPNAME.d/CUSTOM_FILE.conf
/etc/php8.2-sp/fpm-pools.d/APPNAME.d/CUSTOM_FILE.conf
/etc/php8.1-sp/fpm-pools.d/APPNAME.d/CUSTOM_FILE.conf
/etc/php8.0-sp/fpm-pools.d/APPNAME.d/CUSTOM_FILE.conf
/etc/php7.4-sp/fpm-pools.d/APPNAME.d/CUSTOM_FILE.conf
/etc/php7.3-sp/fpm-pools.d/APPNAME.d/CUSTOM_FILE.conf
/etc/php7.2-sp/fpm-pools.d/APPNAME.d/CUSTOM_FILE.conf
/etc/php7.1-sp/fpm-pools.d/APPNAME.d/CUSTOM_FILE.conf
/etc/php7.0-sp/fpm-pools.d/APPNAME.d/CUSTOM_FILE.conf
/etc/php5.6-sp/fpm-pools.d/APPNAME.d/CUSTOM_FILE.conf
In the .conf
file, add the following line.
php_value[setting_name] = setting_value
For example:
php_value[session.gc_maxlifetime] = 86400
To prevent an app from being able to change a setting through either
.user.ini
files or the ini_set()
function, use
php_admin_value
instead of php_value
:
php_admin_value[setting_name] = setting_value
After adding a custom configuration file to an app’s PHP-FPM pool, restart the PHP-FPM service for that PHP version.
Change existing config files for an app’s FPM pool
If you must change an app’s existing PHP-FPM configuration files
rather than adding a new configuration file as shown above,
rename the file’s .conf
file extension to .custom.conf
to prevent ServerPilot from overwriting the file.
After customizing a default PHP-FPM pool configuration file, restart the PHP-FPM service for that PHP version.
Global customizations
The default settings for a PHP version can be customized for all apps using that PHP version.
Customize php.ini
Default PHP settings for a PHP version can be
customized by modifying the PHP version’s php.ini
file.
ServerPilot will not overwrite changes to a PHP version’s php.ini
file.
/etc/php8.4-sp/php.ini
/etc/php8.3-sp/php.ini
/etc/php8.2-sp/php.ini
/etc/php8.1-sp/php.ini
/etc/php8.0-sp/php.ini
/etc/php7.4-sp/php.ini
/etc/php7.3-sp/php.ini
/etc/php7.2-sp/php.ini
/etc/php7.1-sp/php.ini
/etc/php7.0-sp/php.ini
/etc/php5.6-sp/php.ini
After modifying a php.ini
file,
restart the PHP-FPM service for that PHP version.
Add files to conf.d
You can also change default settings for a PHP version
by adding a .ini
file in the PHP version’s conf.d/
directory.
Create the file at the following location.
Replace CUSTOM_FILE
with the name of a file that
does not already exist in the directory.
/etc/php8.4-sp/conf.d/CUSTOM_FILE.ini
/etc/php8.3-sp/conf.d/CUSTOM_FILE.ini
/etc/php8.2-sp/conf.d/CUSTOM_FILE.ini
/etc/php8.1-sp/conf.d/CUSTOM_FILE.ini
/etc/php8.0-sp/conf.d/CUSTOM_FILE.ini
/etc/php7.4-sp/conf.d/CUSTOM_FILE.ini
/etc/php7.3-sp/conf.d/CUSTOM_FILE.ini
/etc/php7.2-sp/conf.d/CUSTOM_FILE.ini
/etc/php7.1-sp/conf.d/CUSTOM_FILE.ini
/etc/php7.0-sp/conf.d/CUSTOM_FILE.ini
/etc/php5.6-sp/conf.d/CUSTOM_FILE.ini
After creating the custom file, restart the PHP-FPM service for that PHP version.
Change existing files in conf.d
Modifications you make to existing files in a PHP version’s
conf.d/
directory will not be overwritten by ServerPilot.
However, if a default file in the PHP version’s conf.d/
directory
has been customized,
future PHP packages updates that include changes to
the default settings in the file will not be applied.
After modifying an existing file in the PHP version’s conf.d/
directory,
restart the PHP-FPM service for that PHP version.