Skip to main content

PHP Settings With .user.ini

A .user.ini file allows you to easily customize PHP settings. Starting with Ubuntu Bionic, only .user.ini settings are supported. All PHP settings defined in this file will be applied recursively to the folder where the file is located.

warning

Ensure that you're only configuring changeable settings and to clear the OPcache after making changes.

Example

/home/www-data/example.com/current/.user.ini
register_globals=on
upload_max_filesize="5M"

Apply Settings

To ensure all settings come into effect immediately, you'll need to clear the PHP OPcache by running nine-flush-fpm after making changes to a .user.ini.

Changeable Configuration Options

Only INI settings with the modes INI_PERDIR, INI_USER and INI_ALL will be recognized in .user.ini-style INI files.

Check the list of php.ini directives to determine if a setting is changeable by a .user.ini.

Migration From .htaccess

If you have been using our old PHP stack, you will need to migrate your PHP settings from .htaccess to .user.ini.

Simply remove the first keyword (php_value, php_flag) and replace it with [KEY]=[VALUE]. Please surround the PHP settings in the .htaccess file with IfModule conditions, otherwise they will cause problems after migration:

Find Affected .htaccess Files

To find affected files, use the following command:

find /home/www-*/ -type f -name .htaccess -exec grep -nH "php_" {} +

.htaccess

<IfModule php7_module>
php_value include_path ".:/usr/local/lib/php"
php_flag display_errors Off
php_value upload_max_filesize 500M
</IfModule>

.user.ini

include_path=".:/usr/local/lib/php"
display_errors=Off
upload_max_filesize=500M