Skip to content

Website & Server Help

Unlimited Webspace Help

Menu
  • Home
  • Apps
  • Website
    • Sending email from a WordPress website hosted on an IONOS server
    • How to increase Upload Max Filesize
    • How to reset a WordPress password
    • 22 Ways To Speed-Up A Plesk Website
  • Server
    • Linux or Plesk Server Error 500
    • Windows Server: File cannot be loaded. The file is not digitally signed.
    • Adding or modifying IP addresses on a Linux server
    • Installing Remote Desktop on Debian 12
    • Installing Remote Desktop on Ubuntu 22.04
    • How To Install a Let’s Encrypt SSL in Apache on Debian/Ubuntu
  • Favs
    • How to Connect to a Server
    • The Ultimate Guide to Setting Up a Proper Plesk Email Server With IONOS
    • The Ultimate IONOS Migration Guide
    • Help! My Plesk Websites Are Down!
    • Running tests for a slow server or dropped packets
    • Checking File System and Hard Drive Health
Menu

Troubleshooting a slow website on a Linux server, Part 3: opcode caching

Posted on January 31, 2023January 31, 2023 by admin

Enabling opcode caching using extensions like APC, XCache, or OpCache, which store the compiled version of PHP scripts in memory, allowing for faster execution. Storing compiled PHP scripts in memory significantly reduces the amount of time required to execute PHP code, improving the overall speed and performance of the website. By caching the compiled version of PHP scripts, the web server can handle more requests with the same amount of resources, reducing the overall load on the server.

To enable opcode caching using extensions like APC, XCache, or OpCache, follow these steps:

  1. Install the extension:
  • APC: pecl install apc
  • XCache: pecl install xcache
  • OpCache: included with PHP 5.5 and above, just enable opcache module in php.ini
  1. Update the php.ini file to enable the extension:
  • For APC:
extension=apc.so
apc.enabled=1
apc.shm_size=64M
  • For XCache:
extension=xcache.so
xcache.size=64M
xcache.var_size=64M
  • For OpCache:
zend_extension=opcache.so
opcache.enable=1
opcache.memory_consumption=128
opcache.max_accelerated_files=10000
  1. Restart the web server to apply the changes.
  2. Verify that the extension is installed and working correctly by creating a PHP file with the following code:
<?php
phpinfo();
?>

And access it via a browser, search for the extension name (e.g. APC, XCache, OpCache) in the output and verify that it’s enabled and working.

  1. Adjust the size of the memory cache to best suit your server’s resources and the needs of your website.

Note: The specific steps to install and configure opcode caching extensions may vary depending on your web server and PHP setup. It’s recommended to consult the official documentation and seek professional assistance if necessary.

Special Offer

The internet's fastest, cheapest, unlimited bandwidth VPS

VPS
1core | 1GB RAM | 10GB NVMe
Unlimited Bandwidth | 1Gbps
$2/month - risk free