When working with PHP, one of the most important files you'll encounter is the php.ini file. This configuration file controls nearly every aspect of how PHP behaves on your server - from error logging to file uploads, session handling, performance tweaks, and security settings.
- What is php.ini?
Depending on your environment, there may be multiple php.ini files.
Sections in php.ini
Although php.ini is a flat configuration file, its directives are logically grouped into sections for readability. Some of the main sections include:
General PHP Settings
engine=On
Enables or disables the PHP engine.
short_open_tag=Off
Allows the use of <? ?> instead of <?php ?>.
precision=14
Sets the number of significant digits in floating-point numbers.
output_buffering=4096
Controls output buffering.
zlib.output_compression=Off
Enables transparent output compression.
Error Handling & Logging
display_errors=Off
Show errors in the browser.
log_errors=On
Save errors to log files.
error_log=php_errors.log
Path to error log file.
error_reporting=E_ALL & ~E_DEPRECATED & ~E_STRICT
Defines the error levels to report.
track_errors=Off
Store the last error in $php_errormsg.
File Uploads & POST Handling
file_uploads=On
Enables HTTP file uploads.
upload_max_filesize=10M
Maximum size of uploaded files.
max_file_uploads=10
Maximum number of files allowed in one request.
post_max_size=20M
Maximum size of POST data (affects file uploads too).
Resource Limits
memory_limit=128M
Maximum memory per script.
max_execution_time=30
Maximum execution time (seconds).
max_input_time=60
Time allowed for input parsing.
max_input_vars=1000
Limits number of input variables.
Session Handling
session.save_handler=files
Session storage method (files, memcached, redis).
session.save_path="/var/lib/php/sessions"
Path to session files.
session.gc_maxlifetime=1440
Lifetime of session data in seconds.
session.cookie_lifetime=0
Lifetime of session cookies.
session.cookie_secure=On
Sends cookies only over HTTPS.
Date & Time
date.timezone="UTC"
Defines default timezone.
Security & Restrictions
allow_url_fopen=Off
Allows accessing files via URL.
allow_url_include=Off
Allows include/require with URL.
disable_functions=exec,passthru,shell_exec,system
Disables dangerous functions.
disable_classes=mysqli,socket,SoapServer
Disables specified classes.
expose_php=Off
Whether PHP exposes its version in headers.
Performance & Caching
realpath_cache_size=4096k
Sets size of realpath cache.
opcache.enable=1
Enables OPcache for performance.
opcache.memory_consumption=128
Amount of memory for OPcache.
opcache.max_accelerated_files=10000
Maximum cached files.
Source: Orkhan Alishov's notes