When a PHP site feels slow, the instinct is to raise limits: more memory, longer execution time, a bigger plan. Usually that misses the point. Speed comes from how much work PHP does on each request and how efficiently it does it. This guide shows you how to measure, where PHP time actually goes, and the changes in cPanel and in your application that make the biggest difference.
Measure before you change anything
Without a baseline you cannot tell whether a change helped. The number that matters most for the server side is TTFB (time to first byte): how long it takes from the request until the first byte of HTML arrives.
The first command measures the normal (possibly cached) page; the second adds a random query string to bypass the page cache and show raw PHP time.
curl -o /dev/null -s -w "TTFB: %{time_starttransfer}s\n" https://example.com/
curl -o /dev/null -s -w "TTFB: %{time_starttransfer}s\n" "https://example.com/?nocache=$RANDOM"
Run each command five times and note the median. A cached page typically answers in well under 0.2 seconds; an uncached WordPress page that takes more than a second is doing too much work.
Add two more measurements:
- PageSpeed Insights reports server response time and its effect on Largest Contentful Paint. Lab numbers vary between runs, so compare before and after rather than chasing a single score.
- Query Monitor (a WordPress plugin) shows PHP time, memory and database queries broken down by plugin. Use it on a staging copy or deactivate it when you are done.
Where PHP spends its time
Think of a request as passing through layers. Each layer that answers early saves all the work below it:
- Page cache — a ready-made HTML copy. PHP does not start at all.
- OPcache — compiled PHP bytecode kept in memory, so files are not parsed on every request.
- Object cache — results of expensive database lookups kept in memory (Redis or Memcached).
- Application code — your CMS, theme, plugins and scheduled tasks.
- Database — queries, indexes and table size.
Optimise from the top. A request served by the page cache costs almost nothing, no matter how heavy the plugins are underneath.
Step by step: the changes that matter
1. Turn on page caching
For most content sites this is the single biggest win. In WordPress, a caching plugin that writes static HTML files is the usual approach; the guide How to make your WordPress site faster compares the options. Check that pages are actually served from cache — many plugins add a response header you can see with curl -sI.
Page cache does not help logged-in users, the admin area, carts or checkout. Those pages always run PHP, which is why the next steps still matter.
2. Choose the right PHP version
In cPanel, open Software › MultiPHP Manager, tick your domain and pick a version. Use the newest version your CMS, theme and plugins officially support. Before switching:
- Take a backup of files and database.
- Switch, then load the front page, a few subpages and the admin area.
- Check
error_logfor new warnings. If something breaks, switch back — it takes seconds.
Note: PHP versions have a limited support life. Running a version that no longer receives security fixes is a risk in itself, independent of speed. The PHP project publishes the dates at php.net/supported-versions.
3. Confirm that OPcache is active
OPcache is enabled on most hosting platforms, but it is worth confirming. Create a temporary file in public_html:
<?php
// opcache-check.php — delete this file after use
$s = function_exists('opcache_get_status') ? opcache_get_status(false) : false;
if (!$s) { exit("OPcache is not active\n"); }
printf("Enabled: %s\nCached scripts: %d\nHit rate: %.1f%%\n",
$s['opcache_enabled'] ? 'yes' : 'no',
$s['opcache_statistics']['num_cached_scripts'],
$s['opcache_statistics']['opcache_hit_rate']);
Open it in the browser, read the result, and delete the file immediately. A healthy site shows a hit rate in the high nineties after it has been running a while.
4. Set limits by need, not by hope
In Software › MultiPHP INI Editor you can adjust per-domain PHP settings. The common ones:
| Setting | What it does | When to raise it |
|---|---|---|
memory_limit | Max memory per script | When the log says "Allowed memory size … exhausted". 256M is a sensible ceiling for most WordPress sites. |
max_execution_time | Max seconds a script may run | Temporarily, for a large import or export. Reset afterwards. |
max_input_vars | Max form fields per request | When large menus or page builders don't save all fields. |
upload_max_filesize / post_max_size | Max upload size | When uploads fail with a size error. |
Higher limits do not make anything faster. They only let a misbehaving script use more resources before PHP stops it.
5. Keep only the extensions you need
In Select PHP Version (where available) or the extension list for your version, enable what your software uses — typically mysqli, curl, gd or imagick, intl, mbstring, zip and opcache. WordPress lists missing recommended modules under Tools › Site Health.
6. Reduce the work PHP has to do
- Plugins: Look for plugins that write to the database on every visit (visitor counters, some statistics tools), calculate "related posts" live, or scan every request. Replace or remove them.
- WP-Cron: WordPress runs scheduled tasks on page views by default. Disable that and use a real cron job instead:
// wp-config.php
define('DISABLE_WP_CRON', true);
Then add this in cPanel › Cron Jobs to run it every 15 minutes:
*/15 * * * * php /home/USERNAME/public_html/wp-cron.php >/dev/null 2>&1
See How to create cron jobs in cPanel for the details.
- Autoloaded options: WordPress loads every "autoload" row from
wp_optionson every request. Check the total size in phpMyAdmin:
SELECT ROUND(SUM(LENGTH(option_value))/1024) AS autoload_kb
FROM wp_options WHERE autoload IN ('yes','on','auto-on','auto');
Anything above roughly 1 MB deserves a look; leftovers from deleted plugins are the usual culprits. Back up the database before removing rows.
Read the resource graphs
Many cPanel hosts show account limits under Metrics › Resource Usage (a CloudLinux feature). It tracks CPU, physical memory, entry processes (simultaneous PHP requests), number of processes and disk I/O. When an account hits a limit, pages slow down or return 503 or 508 errors.
Look for patterns:
- Spikes at night point to backups, imports or cron jobs.
- Spikes in daytime point to traffic, campaigns or aggressive bots.
- Constant CPU with little traffic suggests a plugin doing background work.
Common problems and fixes
- Fast front end, slow admin. The page cache hides the problem for visitors. Find the heavy plugin with Query Monitor and tidy autoloaded options.
- No change after a PHP upgrade. The bottleneck is in the database or a plugin, not PHP itself. Count queries per page.
- 508 errors during a campaign. Landing pages are not cached, so every visitor starts a PHP process. Confirm cache hits on those URLs.
- Things got worse after raising limits. Put the limits back and find the script that needed them. A 500 error after a change is covered in How to fix a 500 Internal Server Error.
When to move up
If caching is in place, plugins are tidy and the resource graphs still show the account hitting its ceiling, the site has simply outgrown the plan. A bigger hosting plan gives you more headroom with the same simple management. A VPS makes sense when you need your own PHP-FPM tuning, Redis or other services, or full control — see VPS vs. web hosting.
In short
Measure TTFB first. Turn on page caching, run the newest supported PHP version with OPcache, set limits only when the logs ask for it, and reduce the work your plugins and scheduled tasks do. Let the resource graphs, not guesswork, decide when it is time to upgrade.
PHP hosting at Hostigan
Hostigan's web hosting uses cPanel, so MultiPHP Manager and the INI editor are where you expect them. If you run WordPress, WordPress hosting adds automatic core updates, and object caching on WP Pro and up.
Frequently asked questions
No. memory_limit only caps how much memory a single script may use. Raise it when the error log says memory was exhausted, not as a speed tweak.