What Is php.ini?
How the php.ini File Controls PHP
php.ini is the main configuration file for PHP, a plain text file that sets how PHP behaves on a server. It holds directives, which are named settings such as upload_max_filesize. Each directive has a value that acts as a rule or a limit.
Some directives are switches, such as whether errors are shown. Others are numbers, such as how many seconds a script may run. PHP reads the file when it starts, so the values apply to every script that runs under that installation.
Not every setting can be changed everywhere. Some are fixed by the server administrator, while others can be overridden for a single site or folder, depending on how PHP is run. A value set in one place may therefore have no effect somewhere else. Errors caused by a misconfigured setting are described in PHP errors.
The Limits Hosting Customers Run Into Most Often
A few directives cause most of the problems people report on shared and managed hosting.
- upload_max_filesize sets the largest single file that can be uploaded through a PHP form, such as a photo or a plugin archive.
- post_max_size limits the total size of a submitted request, and it should be larger than the upload limit.
- max_execution_time sets how long a script may run before PHP stops it, which affects imports and slow tasks.
- max_input_vars caps how many form fields a request can contain, which large admin screens can exceed.
A site that fails to upload a large file or stops partway through an import is often hitting one of these limits rather than a bug in its code. The memory limit is another directive that behaves the same way.
Example: A Theme Upload That Fails
A site owner tries to upload a theme package through the content management system, and the upload fails with a generic error. The file is well within the account's disk space, so the owner suspects the host. Checking the settings shows that the upload limit is lower than the size of the file, so PHP rejects it before it is saved.
Raising the limit usually means changing a host control panel option or the php.ini file, and the change may need a restart of the PHP service before it takes effect.
Frequently asked questions
Can I change php.ini on every hosting plan?
Not always. On shared hosting, many plans do not allow customers to edit the global php.ini. Some hosts offer a control panel setting or a per-folder override file for certain directives, and managed platforms may fix some values entirely. Check what your provider supports before planning around a limit.
Why does a php.ini change sometimes have no effect?
PHP reads its configuration at startup, so a running process can keep old values until it restarts or reloads. A change can also be overridden by another configuration file, a per-directory setting or a value the administrator has locked. If a change seems ignored, confirm which php.ini file the site actually loads, because a server can use more than one.