This is an overview of the recommended directives for your application. The most important directives have been collected here, for a quick review. The whole list of directive is available as a link to the manual, when applicable. When an extension is missing from the list below, either it as no specific configuration directive, or it is not used by the current code.
Directive | Suggestion | Description |
---|---|---|
amqp | ||
amqp.host | localhost | The host to which to connect. |
amqp.vhost | The virtual host on the broker to which to connect. | |
amqp.port | The port on which to connect. | |
amqp.login | guest | The login to use while connecting to the broker. |
amqp.password | guest | The password to use while connecting to the broker. |
Extra configurations | Amqp runtime configuration | |
curl | ||
Extra configurations | Curl runtime configuration | |
date | ||
date.timezone | Europe/Amsterdam | It is not safe to rely on the system's timezone settings. Make sure the directive date.timezone is set in php.ini. |
dba | ||
dba.default_handler | The name of the default handler | |
file | ||
allow_url_fopen | Off | Unless you need to access remote files, it is better to be safe and forbid this feature |
realpath_cache_size | 128k | Determines the size of the realpath cache to be used by PHP. The default value of "16k" is usually too low for modern application that open many files (autoload, fopen, filet_get_contents...). It is recommended to make this value up to 128 to 256k, and reduce it by testing with realpath_cache_get(). |
realpath_cache_ttl | 3600 | Duration of time (in seconds) for which to cache realpath information for a given file or directory. If the application's code doesn't change too often, you may set this directive to 3600 (one hour) or even more. |
Extra configurations | File System runtime configuration | |
filter | ||
filter.default | unsafe_raw | Set the default filter when using functions like filter_input(), filter_var() or their _array() version. Give this a strict level, like 'string' by default, and make every call to the previous functions configure the filters case by case. |
Extra configurations | Filter runtime configuration | |
intl | ||
intl.default_locale | The locale that will be used in intl functions when none is specified (either by omitting the corresponding argument or by passing NULL). These are ICU locales, not system locales. | |
intl.error_level | E_WARNING | The level of the error messages generated when an error occurs in ICU functions. This is a PHP error level, such as E_WARNING. It can be set to 0 in order to inhibit the messages. This does not affect the return values indicating error or the values returned by intl_get_error_code() or by the class specific methods for retrieving error codes and messages. Choosing E_ERROR will terminate the script whenever an error condition is found on intl classes. |
intl.use_exceptions | false | If set to true, an exception will be raised whenever an error occurs in an intl function. The exception will be of type IntlException. This is possibly in addition to the error message generated due to intl.error_level. |
Extra configurations | Intl runtime configuration | |
ldap | ||
Extra configurations | Ldap runtime configuration | |
mbstring | ||
default_charset | UTF-8 | This directive handle encoding for input, internal and output. default_charset |
mbstring.internal_encoding | Do not rely on it | This directive is deprecated or removed since PHP 5.6. It is recommended to use the "default_charset" directive instead. |
Extra configurations | mbstring runtime configuration | |
ob | ||
output_buffering | 4096 | You can enable output buffering for all files by setting this directive to 'On'. If you wish to limit the size of the buffer to a certain size - you can use a maximum number of bytes instead of 'On', as a value for this directive (e.g., output_buffering=4096). As of PHP 4.3.5, this directive is always Off in PHP-CLI. |
output_handler | mb_output_handler or ob_iconv_handler(), ob_gzhandler() or zlib.output_compression; | Use the first suggested values to handle character encoding. Use the second values for on the fly compression; Use your own function if you have one. |
implicit_flush | False | Changing this to TRUE tells PHP to tell the output layer to flush itself automatically after every output block : this has performances penalty. |
opcache | ||
opcache.enable | On | By putting aliases of URI in the php.ini, you won't hardcode the DSN in your code. |
opcache.memory_consumption | 128 | This directive set the amount of opcode cache. The more the better, as long as it doesn't swap. |
opcache.memory_consumption | 4000 | The maximum number of files OPcache will cache. Estimate 32kb a file. |
Extra configurations | Opcache runtime configuration | |
openssl | ||
openssl.cafile | Location of Certificate Authority file on local filesystem which should be used with the verify_peer context option to authenticate the identity of the remote peer. | |
openssl.capath | If cafile is not specified or if the certificate is not found there, the directory pointed to by capath is searched for a suitable certificate. capath must be a correctly hashed certificate directory. | |
pcre | ||
Extra configurations | PCRE runtime configuration | |
pdo | ||
Extra configurations | PDO runtime configuration | |
pgsql | ||
Extra configurations | PostgreSql runtime configuration | |
session | ||
session.name | This directive sets the name of the session, which is also used as cookie. It is recommended to give an explicit name to this, and avoid the default value of PHPSESSID. | |
session.path | Avoid /tmp | This directive sets the path where the session files will be store (if using a file storage). It is recommended to avoid using /tmp, as this folder is accessible to everyone who has access to the machine. Set it to some path that is dedicated to the webserver. |
session.auto_start | 1 | This directive allows the session to be started at request time. This is the default behavior for most web sites. |
session.cookie_httponly | 1 | Mark the session cookie as reserved for HTTP communication. This will prevent the cookie to be available for Javascript, and help prevent XSS (although, not all browsers support it). |
session.use_only_cookies | 1 | Limit the transmission of the session id to cookies. |
session.use_trans_sid | 0 | This will make PHP put the session token in the URL, instead of cookies. This is a security risk, as the token may be easily accessed and shared. It is recommended to avoid this. |
session.cookie_domain | This directive will limit the diffusion of the session cookie to the specified domain name. The more restrictive the better. Aka, session.cookie_domain=".net" will restrict the cookie to every ".net" domains, and not every domain. session.cookie_domain="www.yourdomain.net" will restrict it to the eponymous domain, and won't share the cookie with "images.yourdomain.net", which may be too restrictive. | |
Extra configurations | Session runtime configuration | |
standard | ||
memory_limit | 120 | This sets the maximum amount of memory in bytes that a script is allowed to allocate. This helps prevent poorly written scripts for eating up all available memory on a server. It is recommended to set this as low as possible and avoid removing the limit. |
max_execution_time | 90 | This sets the maximum amount of time, in seconds, that a script is allowed to run. The lower the value, the better for the server, but also, the better has the script to be written. Avoid really large values that are only useful for admin, and set them per directory. |
expose_php | Off | Exposes to the world that PHP is installed on the server. For security reasons, it is better to keep this hidden. |
display_errors | Off | This determines whether errors should be printed to the screen as part of the output or if they should be hidden from the user. |
error_reporting | E_ALL | Set the error reporting level. Always set this high, so as to have the errors reported, and logged. |
log_errors | On | Always log errors for future use |
error_log | Name of a writable file, suitable for logging. | Name of the file where script errors should be logged. |
Extra configurations | Standard runtime configuration | |
Enable DL | ||
enable_dl | Off | Whether or not to enable the dl() function. The dl() function does NOT work properly in multithreaded servers, such as IIS or Zeus, and is automatically disabled on them. |
Error Log | ||
error_log | On | Besides displaying errors, PHP can also log errors to locations such as a server-specific log, STDERR, or a location specified by the error_log directive |
error_log | php_errors.log | Log errors to specified file. PHP's default behavior is to leave this value empty |
Environment | ||
variables_order | EGPCS | Sets the order of the EGPCS (Environment, Get, Post, Cookie, and Server) variable parsing. If 'E' is omited, then $_ENV may be empty. |
Disable features | ||
disable_functions | system, proc_nice, popen, pclose, curl_exec, show_source, pfsockopen, socket_connect, socket_create_listen, socket_create_pair, socket_create, mail, apache_child_terminate, apache_get_modules, apache_get_version, apache_getenv, apache_note, apache_setenv, pcntl_alarm, pcntl_errno, pcntl_exec, pcntl_get_last_error, pcntl_getpriority, pcntl_setpriority, pcntl_sigtimedwait, pcntl_sigwaitinfo, pcntl_strerror, pcntl_wait, pcntl_wifexited, pcntl_wifsignaled, pcntl_wifstopped, pcntl_wstopsig, pcntl_wtermsig, dl, leak, posix_mkfifo, posix_setpgid, posix_setsid, posix_setuid | This directive allows you to disable certain functions for security reasons. It takes on a comma-delimited list of function names. disable_functions is not affected by Safe Mode. ; 17 sensitive functions were found in the code. Don't disable those : posix_kill, proc_get_status, pcntl_signal_dispatch, pcntl_signal, proc_terminate, proc_open, shell_exec, proc_close, fsockopen, passthru, exec, symlink, pcntl_sigprocmask, pcntl_waitpid, pcntl_wexitstatus, curl_multi_exec, pcntl_fork |
disable_classes | phar | This directive allows you to disable certain classes for security reasons. It takes on a comma-delimited list of class names. disable_classes is not affected by Safe Mode. This directive must be set in php.ini. ; 3 sensitive classes were found in the code. Don't disable those : , Phar, \Phar |
File Upload | ||
upload_max_filesize | 2M | This is the maximum uploaded size. It is recommended to keep this value as low as possible. |
max_file_uploads | 1 | This is the maximum number of uploaded files in a single request. |
upload_tmp_dir | /tmp/php_upload | Upload directory where PHP stores the temporary files. It is recommended to set this value, and separate it from other temporary directories. |
post_max_size | 2M | This is the maximum amount of data that PHP will accept in a POST request. It has to be higher or equal to upload_max_filesize. For security reasons, it should be as low as possible, to prevent PHP using too much memory. |