How to Speed Up cPanel Hosting Website: Practical Guide
By Yoga · 16 Jun 2026 · 7 min read
If your website feels sluggish on shared cPanel hosting, you're not alone. Slow load times hurt user experience and search rankings alike. The good news: cPanel exposes several server-side levers you can pull without touching a single line of infrastructure code. This guide walks you through the most impactful optimizations — PHP version selection, OPcache configuration, MySQL query caching, and image compression — with concrete steps for each.
1. Upgrade to a Modern PHP Version
PHP 7.4 and earlier are end-of-life. If your hosting account still runs PHP 5.6 or 7.x, you're leaving serious performance on the table. PHP 8.x ships with a significantly improved JIT (Just-In-Time) compiler that can cut script execution time by 30–50% on compute-heavy pages.
How to Change Your PHP Version in cPanel
- Log in to cPanel and navigate to Software → Select PHP Version (sometimes listed as MultiPHP Manager).
- Choose PHP 8.1 or PHP 8.2 from the dropdown for your domain.
- Click Apply.
- Visit your website and check for any compatibility errors. If plugins break, test in a staging environment first.
Tip: Before switching production, clone your site to a staging subdomain, change its PHP version there, and verify nothing breaks. Many hosts let you set different PHP versions per subdomain in MultiPHP Manager.
PHP Extensions That Matter for Speed
While you're in the PHP settings panel, make sure these extensions are enabled:
mysqliorpdo_mysql— required for efficient database connectionsjson— parsed natively at C speedintl— faster locale operationszlib— enables gzip output compression
Disable extensions you don't need (e.g., imap, ldap) to reduce interpreter overhead on every request.
2. Enable and Configure OPcache
Every time PHP runs a .php file, it compiles the source into bytecode. Without caching, this happens on every single request. OPcache stores compiled bytecode in shared memory so subsequent requests skip the compilation step entirely.
Enabling OPcache via cPanel
- Go to Software → Select PHP Version.
- Click on PHP Extensions.
- Check the box next to opcache and save.
That's the minimum. But the default OPcache settings are conservative. You can tune them via a custom php.ini or .user.ini file in your document root:
; .user.ini — place in public_html or your app root
opcache.enable=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=10000
opcache.revalidate_freq=60
opcache.validate_timestamps=1
opcache.save_comments=1
What These Settings Do
| Directive | Recommended Value | Purpose |
|---|---|---|
memory_consumption |
128 MB | RAM allocated for cached bytecode |
interned_strings_buffer |
16 MB | Deduplicated string storage |
max_accelerated_files |
10000 | Max PHP files cached (raise for large apps) |
revalidate_freq |
60 seconds | How often OPcache checks if files changed |
validate_timestamps |
1 | Set to 0 on production for max speed (clear cache on deploy) |
For a WordPress site with ~3,000 PHP files, max_accelerated_files=5000 is usually enough. For a large WooCommerce store with many plugins, bump it to 10,000.
Important: After you deploy code changes, clear OPcache. You can do this programmatically with
opcache_reset()called from a protected PHP script, or by restarting PHP-FPM if your host allows it.
3. Optimize MySQL Queries and Caching
A slow database is the most common bottleneck for CMS-based sites. cPanel-managed MySQL instances give you a few tools to address this without needing root access.
Enable Query Caching via WordPress (or Your App)
MySQL's built-in query cache was removed in MySQL 8.0. On older MySQL 5.7 instances you may still have it, but it's unreliable under write-heavy loads. A better strategy is application-level caching.
For WordPress, install a persistent object cache backed by file-based caching if Redis or Memcached isn't available:
// In wp-config.php, enable the object cache drop-in
define('WP_CACHE', true);
Then use a plugin like W3 Total Cache or WP Super Cache to write full-page HTML output to disk. Subsequent requests for the same URL skip PHP and MySQL entirely and serve a static file — this is the single biggest win for WordPress sites.
Identify Slow Queries with MySQL Slow Query Log
If you have SSH access (available on most cPanel plans), ask your host to enable the slow query log or check if it's already on:
# Connect via SSH, then:
mysql -u your_db_user -p your_db_name
-- Check if slow query log is enabled
SHOW VARIABLES LIKE 'slow_query_log';
SHOW VARIABLES LIKE 'long_query_time';
If you can't access my.cnf, use a plugin like Query Monitor (WordPress) to surface slow queries directly in your admin dashboard.
Index Your Database Tables
Missing indexes are behind most slow queries. Run this in phpMyAdmin (accessible from cPanel → Databases → phpMyAdmin):
-- Find tables with no primary key (a common oversight)
SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'your_database_name'
AND table_name NOT IN (
SELECT DISTINCT table_name
FROM information_schema.statistics
WHERE index_name = 'PRIMARY'
AND table_schema = 'your_database_name'
);
Also, periodically run OPTIMIZE TABLE on large, frequently updated tables (like WordPress wp_options or WooCommerce order tables) to reclaim fragmented space.
4. Compress and Optimize Images at the Server Level
Images typically account for 60–80% of a page's total byte weight. Serving unoptimized images from cPanel hosting wastes bandwidth and slows every page load.
Enable Gzip Compression for Text Assets
First, make sure gzip is enabled for HTML, CSS, and JavaScript. Add this to your .htaccess file (Apache is the default web server on most cPanel hosts):
# Enable Gzip compression
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml
AddOutputFilterByType DEFLATE text/css application/javascript
AddOutputFilterByType DEFLATE application/json application/xml
AddOutputFilterByType DEFLATE image/svg+xml
</IfModule>
This alone can reduce HTML and CSS payload by 60–70%.
Compress Images Before Upload
The most reliable method is to compress images before they hit your hosting account:
- JPEG: Use
mozjpegorjpegoptimlocally. A quality setting of 80–85 is visually lossless for most photos. - PNG: Use
pngquantfor lossy compression (often 60–80% smaller) oroptipngfor lossless. - WebP: Convert all images to WebP format, which is 25–35% smaller than JPEG at equivalent quality.
If you're on WordPress, plugins like Imagify, ShortPixel, or Squoosh (a free Google tool) automate this for your media library.
Serve Images in WebP via .htaccess
You can instruct Apache to serve a .webp version of an image automatically when a WebP-capable browser requests a .jpg or .png:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{REQUEST_FILENAME} (.+)\.(jpe?g|png)$
RewriteCond %{REQUEST_FILENAME}.webp -f
RewriteRule ^ %{REQUEST_FILENAME}.webp [T=image/webp,L]
</IfModule>
<IfModule mod_headers.c>
Header append Vary Accept env=REDIRECT_accept
</IfModule>
This requires that the .webp counterpart already exists alongside the original. You can batch-generate WebP files via SSH using cwebp if your host has it installed, or pre-generate them locally and upload.
5. Add Browser Cache Headers
Telling browsers to cache static assets locally means repeat visitors don't re-download images, stylesheets, and scripts. Add this block to .htaccess:
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType text/html "access plus 1 hour"
</IfModule>
Pair this with cache-busting filenames (e.g., style.v2.css) whenever you update assets, so returning users get the new version.
Putting It All Together
Here's a quick checklist to run through for any cPanel-hosted site:
- PHP 8.1+ enabled in MultiPHP Manager
- OPcache enabled with tuned
.user.ini - Full-page caching plugin active (WordPress) or application-level caching implemented
- Slow queries identified and indexes added where missing
- Images compressed to WebP with fallback
.htaccessrewrite rules - Gzip compression active for text assets
- Browser cache headers set via
mod_expires
Each of these steps is independent — you don't need to do all of them at once. Start with PHP version and OPcache, as those give the highest return for the least effort. Then tackle images, which often produce the most visible improvement for end users.
If you're looking for cPanel hosting that gives you control over PHP versions, .user.ini customization, and SSH access to implement these optimizations, GoCelerus offers shared and WordPress hosting plans built with these developer-friendly features in mind.
Speed is never a one-time fix. Set a monthly reminder to check your Core Web Vitals in Google Search Console, profile your slowest pages, and revisit this checklist. Small, consistent improvements compound into a noticeably faster site over time.