Linux VPS7 min read•Last updated: •By SkyRain Cloud Team

How to Find and Edit php.ini on a Linux Server

"Upload exceeds the maximum allowed size", "Allowed memory size exhausted" and "Maximum execution time exceeded" are three of the most common PHP errors, and they are all fixed in the same place: php.ini, PHP's main configuration file. The catch is that a server usually has several php.ini files, and editing the wrong one changes nothing.

This guide shows how to find the file your website actually uses, which settings to change for common problems, how to set different limits per site, and how to apply the changes without restarting the whole server.

Quick answer

Each PHP mode has its own php.ini. On Ubuntu with PHP-FPM (the usual Nginx setup), web requests use /etc/php/8.3/fpm/php.ini (adjust the version); Apache with mod_php uses /etc/php/8.3/apache2/php.ini; and the command line uses /etc/php/8.3/cli/php.ini. Confirm with a temporary phpinfo() page (Loaded Configuration File). Edit the setting, then reload PHP-FPM with sudo systemctl reload php8.3-fpm or restart Apache.

Step 1: Find the php.ini your site uses

How PHP runsTypical php.ini on Ubuntu/DebianApply changes with
PHP-FPM (Nginx or Apache with FPM)/etc/php/8.3/fpm/php.inisudo systemctl reload php8.3-fpm
Apache mod_php/etc/php/8.3/apache2/php.inisudo systemctl restart apache2
Command line (cron, Composer, WP-CLI)/etc/php/8.3/cli/php.iniTakes effect on the next command
AlmaLinux/Rocky (php-fpm)/etc/php.inisudo systemctl reload php-fpm

Running php --ini in a terminal shows the CLI file only, which is the most common source of confusion. To see what the web server uses, create a temporary file in your site's root:

<?php phpinfo();

Open it in a browser and look for Loaded Configuration File and Scan this dir for additional .ini files. Delete the file immediately afterwards: phpinfo output reveals details an attacker would find useful.

Php.ini – SkyRain Cloud servers in India

Step 2: Change the settings that fix common errors

SettingDefault (typical)Example valueFixes
upload_max_filesize2M64MUploads rejected as too large
post_max_size8M64MLarge forms or uploads failing silently (keep it at least as big as upload_max_filesize)
memory_limit128M256M"Allowed memory size exhausted"
max_execution_time30120Long imports or reports timing out
max_input_vars10003000Large menus or settings pages not saving
date.timezone(unset)Asia/KolkataWrong times in logs and orders
display_errorsOffOff in productionErrors exposed to visitors

Open the file with sudo nano /etc/php/8.3/fpm/php.ini, search for each setting (Ctrl+W in nano), and edit the existing line instead of adding a duplicate at the end. Lines starting with ; are comments. The full list of directives is in the PHP manual's php.ini directive list.

Uploads also need a web server change

Nginx has its own upload limit. If uploads still fail after raising PHP's limits, add client_max_body_size 64M; to the server block and run sudo nginx -t && sudo systemctl reload nginx.

Step 3: Apply and verify

sudo php-fpm8.3 -t
sudo systemctl reload php8.3-fpm

The first command tests the configuration; a reload applies it without dropping requests in progress. Then reload your phpinfo page (create it again briefly) or check one value from the FPM side with a small script that echoes ini_get('upload_max_filesize').

Per-site settings instead of global changes

Raising limits for every site on a server is rarely necessary. Better options:

  • PHP-FPM pool overrides. Each site's pool file (for example /etc/php/8.3/fpm/pool.d/shop.conf) can set its own values:
    php_admin_value[upload_max_filesize] = 128M
    php_admin_value[post_max_size] = 128M
    php_admin_value[memory_limit] = 512M
    php_admin_value cannot be overridden by the application; php_value can.
  • .user.ini files. PHP-FPM reads a .user.ini in the site's directory for settings that are allowed per directory. Changes are picked up after a few minutes (the user_ini.cache_ttl setting).
  • Control panels. cPanel's MultiPHP INI Editor and Plesk's PHP settings write these overrides for you.

Do not raise memory_limit blindly

memory_limit is a per-request ceiling, not a pool. If PHP-FPM can run 30 workers and each may use 512 MB, the worst case is 15 GB. Raise it only for the sites that need it, and size pm.max_children to fit your RAM, as explained in our Ubuntu VPS optimisation guide. If you see processes killed by the kernel after raising limits, the troubleshooting guide shows how to confirm it.

php.ini settings for large imports

Importing a big WordPress export, a product CSV or a database backup through a web interface often hits several limits at once: upload size, post size, execution time and memory. Raise them temporarily in the site's pool file, complete the import, then set them back. For database imports, the command line is usually the better route because it avoids PHP limits entirely; see how to export and import a MySQL database.

Common php.ini mistakes

  • Editing the CLI file and wondering why the website did not change.
  • Raising upload_max_filesize but not post_max_size or Nginx's client_max_body_size.
  • Forgetting to reload PHP-FPM after editing.
  • Leaving display_errors = On in production.
  • Leaving a phpinfo file on the server.
  • Upgrading PHP (for example from 8.2 to 8.3) and forgetting that the new version has its own php.ini.

Why developers choose SkyRain Cloud VPS

PHP sites run best with room to tune. SkyRain Cloud Intel VPS plans include:

  • KVM virtualization. Your own kernel and allocated vCores, so you can tune the system the way this guide describes.
  • Intel Xeon Platinum 8269CY hosts. Server-class Cascade Lake CPUs with DDR4 ECC memory.
  • NVMe SSD storage on every plan, which keeps I/O wait low for databases and builds.
  • Full root access to install and configure whatever your stack needs.
  • Unmetered 1 Gbps port in India, close to your users.
  • Simple billing and real support. Monthly billing in rupees with UPI, plus 24/7 tickets, WhatsApp and Discord.

Frequently Asked Questions

Where is php.ini on Ubuntu?
In /etc/php/VERSION/, with separate files for fpm, apache2 and cli, for example /etc/php/8.3/fpm/php.ini for PHP-FPM.
Why didn't my php.ini change take effect?
You may have edited the CLI file instead of the FPM or Apache one, or not reloaded PHP-FPM or Apache afterwards.
How do I increase the upload size limit in PHP?
Raise upload_max_filesize and post_max_size in the web server's php.ini, raise client_max_body_size in Nginx if you use it, then reload PHP-FPM and Nginx.
Do I need to restart the server after editing php.ini?
No. Reload PHP-FPM (sudo systemctl reload php8.3-fpm) or restart Apache if you use mod_php.
Can I set different PHP limits for different sites?
Yes. Use php_admin_value lines in each site's PHP-FPM pool file, a .user.ini file in the site's directory, or your control panel's PHP settings.
What timezone should I set for an Indian website?
Set date.timezone = Asia/Kolkata so PHP dates and times match Indian Standard Time.

Conclusion

Editing php.ini is simple once you edit the right file: FPM for most Nginx sites, the Apache file for mod_php, and CLI for scripts. Change the setting that matches the error, keep post_max_size and the web server's limit in step with uploads, reload PHP-FPM, and prefer per-pool overrides for sites with special needs. Keep memory limits in proportion to your RAM and workers.

For a VPS with full control over PHP, see our Intel VPS plans.

SkyRain Cloud Intel Xeon VPS Plans

KVM VPS on Intel Xeon Platinum 8269CY (up to 3.80 GHz Turbo) with DDR4 ECC memory, NVMe SSD, full root access and an unmetered 1 Gbps port.

PlanvCoresRAMStorageNetworkPriceGood forBuy
VPS 1 — Intel28 GB DDR4 ECC40 GB NVMe SSD1 Gbps, unmetered₹649/monthBusiness websites, small apps, scheduled jobs and botsOrder
VPS 2 — Intel416 GB DDR4 ECC80 GB NVMe SSD1 Gbps, unmetered₹1,169/monthBusiness software, mid-size databases, several sites on one serverCheck stock
VPS 3 — Intel832 GB DDR4 ECC150 GB NVMe SSD1 Gbps, unmetered₹2,249/monthERP/CRM stacks, heavier databases, multiple production appsCheck stock
VPS 4 — Intel1664 GB DDR4 ECC250 GB NVMe SSD1 Gbps, unmetered₹4,299/monthHigh-memory workloads and consolidated production serversCheck stock

Prices are monthly in INR as listed on the SkyRain Cloud store (verified 2026-11-23). Live stock and final price are shown at checkout.

Instant UPI • ₹649/mo
Fast KVM Cloud Provisioning