PHP Security

PHP Configuration Overrides

Mode Meaning
PHP_INI_USER Entry can be set in user scripts (like with ini_set())
PHP_INI_PERDIR Entry can be set in php.ini, .htaccess or httpd.conf
PHP_INI_SYSTEM Entry can be set in php.ini or httpd.conf
PHP_INI_ALL Entry can be set anywhere

Configuration Settings

open_basedir

Limits all file operations to the defined directory and below. This directive makes most sense if used in a per-directory or per-virtualhost web server configuration file.

Also it is prudent to disable symlink() function

disable_functions

Disable certain PHP functions from executing. Will throw a security warning error when they are used in code.

expose_php

Adds a header to the HTTP response detailing the PHP version used.

display_errors

Includes error output with script execution.

html_errors

Displays errors with HTML tags

post_max_size

Maximum size of POST data that PHP will accept.

enable_dl

Allows loading external PHP modules

file_uploads

Allows uploading files.

upload_max_filesize

The max filesize of an uploaded file.

max_file_uploads

Maximum number of files that can be uploaded via a single request.

allow_url_fopen

Whether to allow the treatment of URLs (like http: or ftp:) as files.

allow_url_include

Whether to allow include/require to open URLs (like http: or ftp:) as files.

session.use_only_cookies

This option enables administrators to make their users invulnerable to attacks which involve passing session ids in URLs

session.cookie_httponly

Whether or not to add the httpOnly flag to the cookie, which makes it inaccessible to browser scripting languages such as JavaScript.

session.hash_function

Allows you to specify the hash algorithm used to generate the session IDs. '0' means MD5 (128 bits) and '1' means SHA-1 (160 bits).