Use .user.ini files to configure PHP
A .user.ini
file allows you to change the configuration
of PHP on a per-app and per-directory basis.
A .user.ini
file is PHP’s equivalent of Apache’s .htaccess
file.
Create a .user.ini
file in an app’s web root directory to apply
the file’s directives to all requests for the app.
apps/APPNAME/public/.user.ini
The directives in a .user.ini
file can be
overridden by a .user.ini
file in a subdirectory.
Use the phpinfo()
function to
confirm a PHP setting was changed.
Create and edit .user.ini files
You can create and edit .user.ini
files either
over SSH or with an SFTP client.
Learn how to edit files over SSH.
Show hidden .user.ini files
Files beginning with a dot (.
) are often hidden in directory listings.
To show hidden files when using the ls
command,
add the -a
(all files) flag.
ls -a apps/APPNAME/public/
To show hidden files in the Cyberduck SFTP client:
- Open Cyberduck.
- Click View in the menu bar.
- Select Show hidden files.
To show hidden files in the Filezilla SFTP client:
- Open Filezilla.
- Click Server in the menu bar.
- Select Force showing hidden files.
Format of .user.ini files
Each line in a .user.ini
file has the format:
setting_name = setting_value
Lines in .user.ini
files that start with a semicolon (;
) are comments and are ignored by PHP.
Settings that can be changed
Most PHP settings can be changed through a .user.ini
file.
To confirm that a setting can be changed through a .user.ini
file,
check the “Changeable” column in
PHP’s list of settings.
A setting with the “Changeable” mode of INI_PERDIR or INI_USER
can be changed through a .user.ini
file.
Change max_execution_time
The PHP max_execution_time
is the number of seconds PHP will
allow a script to run before PHP terminates the script.
Change the PHP
max_execution_time
setting:
; The value of max_execution_time is the number of seconds.max_execution_time = 120
Change memory_limit
Change the PHP
memory_limit
setting.
; The value of memory_limit is the number of bytes. Use -1 for no limit.memory_limit = -1
To completely disable PHP’s memory limit, use the following.
memory_limit = -1
Change max_input_vars
Change the PHP
max_input_vars
setting.
; The value of max_input_vars is the number of input variables.max_input_vars = 5000
Change upload_max_filesize and post_max_size
To increase the maximum size of files that can be uploaded to an app,
change the PHP
upload_max_filesize
and
post_max_size
settings.
upload_max_filesize = 100Mpost_max_size = 100M
Disable register_argc_argv
To disable PHP’s
register_argc_argv
,
use the following.
register_argc_argv = 0
Change the PHP timezone
The default timezone used by all PHP date/time functions is UTC regardless of your server’s timezone.
To change the PHP timezone for an app, use the following.
date.timezone = America/Los_Angeles
See PHP’s
list of supported timezones
to find the names of all possible timezones you can use for the date.timezone
setting.