What is php.ini?
PHP is the language many websites run on. The file php.ini holds its settings. It sets limits such as the biggest upload, the time a script may run and how much memory it may use. "Global" means it applies to all sites on the server, like house rules that every room must follow.
You need root access for this guide. Root is the main administrator login of the server.
Option 1: Use WHM (cPanel servers)
- Log in to WHM as root at
https://your-server-ip:2087. - Type MultiPHP INI Editor in the search box. Open it.
- Pick the Basic Mode tab. Choose the PHP version from the list.
- Change the values you need, for example
memory_limitorupload_max_filesize. - Click Apply.
For the full file, use the Editor Mode tab. Edit the text, then click Save.
Option 2: Edit the file by hand
- Connect with SSH. SSH is a safe way to type commands on a remote server.
- Find the file.
This prints the path of the file PHP loads. It is oftenphp --ini/etc/php.ini. - Copy it first, as a backup.
cp /etc/php.ini /etc/php.ini.bak - Open it.
nano /etc/php.ini - Press Ctrl+W to search for the setting, such as
memory_limit. - Change the value. Lines that start with a semicolon (;) are comments and do nothing. Remove the semicolon to switch a line on.
- Press Ctrl+O, Enter, then Ctrl+X to save and leave.
- Restart the web server so the change loads.
service httpd restart
Useful settings
| Setting | What it does |
|---|---|
memory_limit | Memory one script may use |
upload_max_filesize | Biggest single upload |
post_max_size | Biggest form submission |
max_execution_time | Seconds a script may run |
Warning: A typing mistake can stop PHP from loading and take sites offline. Keep the
.bak copy so you can put it back.Quick recap
- php.ini holds PHP settings for all sites.
- On cPanel, use MultiPHP INI Editor in WHM.
- Or edit the file by hand and restart the web server.
- Always make a backup copy first.