Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Change the global php.ini file on your server

This guide shows you how to change PHP settings for every site on your server.

Dedicated Servers2 min read13 steps

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)

  1. Log in to WHM as root at https://your-server-ip:2087.
  2. Type MultiPHP INI Editor in the search box. Open it.
  3. Pick the Basic Mode tab. Choose the PHP version from the list.
  4. Change the values you need, for example memory_limit or upload_max_filesize.
  5. Click Apply.

For the full file, use the Editor Mode tab. Edit the text, then click Save.

Option 2: Edit the file by hand

  1. Connect with SSH. SSH is a safe way to type commands on a remote server.
  2. Find the file.
    php --ini
    This prints the path of the file PHP loads. It is often /etc/php.ini.
  3. Copy it first, as a backup.
    cp /etc/php.ini /etc/php.ini.bak
  4. Open it.
    nano /etc/php.ini
  5. Press Ctrl+W to search for the setting, such as memory_limit.
  6. Change the value. Lines that start with a semicolon (;) are comments and do nothing. Remove the semicolon to switch a line on.
  7. Press Ctrl+O, Enter, then Ctrl+X to save and leave.
  8. Restart the web server so the change loads.
    service httpd restart

Useful settings

SettingWhat it does
memory_limitMemory one script may use
upload_max_filesizeBiggest single upload
post_max_sizeBiggest form submission
max_execution_timeSeconds 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.