JoomlaWorks

Member Dashboard
  • Home
  • Extensions
    • Commercial
      • Frontpage Slideshow
      • K2 Plugin for sh404SEF
      • Simple Image Gallery Pro
      • SocialConnect
    • Free
      • K2
      • AllVideos
      • DISQUS Comments for Joomla!
      • IAKI (Import As K2 Image)
      • Quick Menu (for Joomla 4)
      • Simple Image Gallery
      • Simple RSS Feed Reader
    • Free On Github
      • Akismet for Kunena
      • Fill It Up
      • K2 Example Plugin
      • K2 Links for JCE
      • Rebuild K2 Image Cache (CLI utility for K2)
      • TinyLetter Subscribe
      • URL Normalizer
      • User Extended Fields for K2
  • Templates
    • Commercial Templates
      • Anagram
      • Archetype
      • BusinessOne
      • Ibento
      • Janaro
      • Kiji
      • Matchbox
      • nuMuzik
      • RadioWave
      • Toreda
    • Free Templates
      • nuModusVersus
      • Takai
  • Demos
    • Joomla Extension Demos
    • Joomla Template Demos
    • WordPress Plugin Demos
  • Labs
    • Web Apps
      • JSON 2 JSONP
      • Feed Reader (bookmarklet)
      • Device Info
  • Support
    • Documentation for Joomla Extensions
      • AllVideos
      • Frontpage Slideshow
      • Simple Image Gallery
      • Simple Image Gallery Pro
      • SocialConnect
    • Documentation for Joomla Templates
      • General Resources
        • Installation
        • Content
        • Customization
      • Commercial Templates
      • Free Templates
    • Get Help
      • Community Forum
        • Recent Topics
        • Categories
        • Create free account
      • Help Desk
      • Contact us by e-mail
      • Contact us on Facebook Messenger
      • Contact us on Twitter
  • About
    • Blog
    • Company
    • License & Terms of Service
    • Privacy Policy
  • My Account
01 12 2010
Written by  JoomlaWorks
Published in Blog
Tagged under
  • +apc
  • +cache
  • +joomla
  • +Performance
  • +session
  • +apcu
  • +mysql
  • +apache
  • +fastcgi
  • +cpanel
  • +whm
23 comments

Install APC/APCu on a WHM/cPanel server the easy way and boost your site's performance!

Install APC/APCu on a WHM/cPanel server the easy way and boost your site's performance!
If you run a popular Joomla (or WordPress, Drupalor or any other PHP based CMS) website on either a dedicated server or VPS running WHM/cPanel, chance is you may have stumbled upon performance issues at some point.

Although improving Joomla's performance is a task that requires in-depth analysis, I thought I'd just write a couple of words on improving one aspect of your site's performance quickly and efficiently: PHP execution by using the APC or APCu opcode caching modules. Keep in mind that APC is compatible with PHP up to version 5.3.x. APCu replaces APC for PHP versions 5.4.x or newer and it's currently under active development.

Since PHP 5.3.x is considered obsolete, I'll cover the steps to have APCu installed on your server. If you run PHP 5.3.x either consider updating to 5.5.x/5.6.x or follow the steps below making sure you replace any "apcu" reference with just "apc" (minus the "u").

There are many tutorials out there covering how to install APCu from command line (as root user), but none on how to install APCu on a WHM/cPanel server " the easy way ". And it's actually pretty easy provided your server is executing PHP in FastCGI mode (the most optimal setup). Default cPanel installations usually run PHP in suPHP mode, which does not allow APCu to be installed. If you have full control of the server, you can use EasyApache in WHM to "rebuild" your system with PHP in FastCGI mode.

FastCGI mode is known to be a fast and secure way to run PHP on your server... FastCGI is also preferred compared to mod_php as it allows websites to execute with the user's permissions (like with suPHP) and as some claim, it's also the fastest from all other PHP builds.

If you want to re-build your server with FastCGI, you can grab a ready-made profile to upload and use in WHM: http://engintron.com/files/cpanel/engintron.dtd

Don't bother trying to install APCu via cPanel's PECL modules installer. It's just broken.

Now, assuming you have PHP in FastCGI mode running on your WHM/cPanel (version 11.48+) based server, here are the steps to install APCu on your server:

1. Install packages

Login via SSH as "root" user on your cPanel server and execute the following commands:

$ yum install make pcre-devel
$ pecl install channel://pecl.php.net/APCu-4.0.10

The first line installs some required packages. Year 2014 or later builds of cPanel should have these installed. If you run the command and the packages are already installed, nothing will happen. The second line will retrieve the latest 4.x build of APCu directly from the PECL code repositories which is compatible with (at the time of writing) the PHP versions (5.x) that ship with cPanel. APCu's v5.x is currently compatible with PHP 7.x only so don't install that until cPanel includes this PHP version too.

Restart Apache via WHM

2. Edit php.ini

Now edit the master php.ini file of the server - usually located in /usr/local/lib/php.ini - to add a couple of configuration options for APCu. Open the file (either with some editor like Coda or via "nano" or "vim") and append these lines at the very bottom of the php.ini file:

[apcu]
apc.enabled = 1
apc.shm_size = 128M

The second line will create a memory pool of 128MBs of cache available from the system to APCu. If you have lots of sites that will use APCu for caching, adjust accordingly.

Restart Apache via WHM.

3. Adjust settings for APCu

If you wish to adjust the APCu values above, you can now do so via "PHP Configuration Editor" in WHM, after selecting the "Advanced Mode" editing option. These 2 values will be at the very top. APCu has a lot more options but "apc.shm_size" is obviously the most critical as it defines the memory pool to hold all cache objects coming from your CMS (Joomla, WordPress etc.).

Remember that whenever your edit your PHP's configuration, you need to restart Apache for the changes to take effect.

4. Keep in mind

If you rebuild your cPanel's LAMP stack with EasyApache, you need to re-install APCu as your changes will be lost. Just follow steps 1-3 once more.

What next?

Wanna go the extra mile and do more to improve your cPanel server's performance, besides the FastCGI setup and APCu? You can obviously optimize your Apache, FastCGI & MySQL configurations:

  • For Apache (make sure you run EasyApache and check Apache 2.4 - it's way better than Apache 2.2), you can have a look at Linode's knowledge base as a starting point https://www.linode.com/docs/websites/apache-tips-and-tricks/tuning-your-apache-server or better still, try using ApacheBuddy to get insights on your existing configuration: https://github.com/gusmaskowitz/apachebuddy.pl

    To give you an idea, this is a good starting point:

    StartServers 5
    MinSpareServers 5
    MaxSpareServers 10
    ServerLimit 500
    MaxRequestWorkers 500 (this option was previously called MaxClients in Apache v2.2)
    MaxRequestsPerChild 4000
    Timeout 20

    In cPanel, these Apache directives can be configured in "Apache Configuration" (in WHM).
  • For MySQL have a look at this bulletproof configuration we created with the help of Percona (the MySQL experts) a few years ago and updated to today's needs & uses: https://gist.github.com/fevangelou/fb72f36bbe333e059b66 - the file to edit on your server is: /etc/my.cnf
  • For FastCGI/PHP have a look here http://2bits.com/articles/apache-fcgid-acceptable-performance-and-better-resource-utilization.html & here https://www.cloudlinux.com/blog/clnews/perfecting-fastcgi-settings-for-shared-hosting.php - the file to edit on your server is: /usr/local/apache/conf/php.conf

    After you edit this file, you need to "merge" your changes with cPanel so they don't get reset to the defaults when Apache's configuration is updated. If however you rebuild Apache & PHP via EasyApache, you need to run the entire process as the changes to php.conf are reset.

    So after you edit the php.conf file, execute the following commands as root via SSH:

    $ /usr/local/cpanel/bin/apache_conf_distiller --update
    $ /scripts/rebuildhttpdconf
    $ service httpd restart
  • Use Engintron: http://engintron.com/

(updated Jan 2016)
Read 245481 times Last modified on Sunday, 03 January 2016 19:38

23 comments

  • Helpdesk Helpdesk 07 Jan 2011
    Comment Link


    Thanks for the tip. This post can help a lot to all the joomla users out there.

  • CompleteWebCare CompleteWebCare 02 Jan 2011
    Comment Link


    We implemented that for a large client site about 2 months ago and saw dramatic results that were further improved by gzipping. Great post!

  • gswahhab gswahhab 02 Dec 2010
    Comment Link


    Great post. I recently did a lot of research on APC along with xcache and memcache. Many people don't know that Joomla's file caching only works when a user is NOT logged in. My question is does APC caching work the same as Joomla file caching in terms that it only works when not logged in or does it work site wide? I always assumed it did but when i learned about the previous file caching does not it made me question APC. When we have previously used APC caching it has produced huge performance increases.

  • Start
  • Prev
  • 1
  • 2
  • Next
  • End

Leave a comment

Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.

back to top
BY MAIL BY RSS

Archives

  • May 2024 (1)
  • March 2023 (1)
  • January 2022 (1)
  • July 2021 (2)
  • May 2021 (1)
  • February 2021 (1)
  • December 2020 (1)
  • September 2020 (1)
  • June 2020 (1)
  • May 2020 (1)
  • February 2020 (1)
  • January 2020 (5)

Tag Cloud

1.6 allvideos announcement apache community cpanel development frontpage slideshow future joomla k2 opinion plugin release simple image gallery simple image gallery pro simple rss feed reader socialconnect update video

Latest Entries

  • K2 will not be made available for Joomla 4/5 - change of course
    Written by  JoomlaWorks
    30 May 2024
  • New free extension release: Quick Menu (for Joomla 4)
    Written by  JoomlaWorks
    06 Mar 2023
  • Simple Image Gallery (free) v4.2 released
    Written by  JoomlaWorks
    07 Jan 2022
  • Simple Image Gallery Pro v3.9.1 released (bug-fix release)
    Written by  JoomlaWorks
    26 Jul 2021
  • Simple Image Gallery Pro v3.9.0 released
    Written by  JoomlaWorks
    05 Jul 2021

Join Our Newsletter

Enter your e-mail address to subscribe to our new or updated product notifications. We send combined newsletters, so we won't spam you every week :)

Get Social

  • Twitter
  • GitHub
  • Facebook
  • GitHub (K2)
  • YouTube
  • Speaker Deck

Grab Our Feeds

  • Extension Updates
  • Blog
  • Videos
  • Presentations
Copyright © 2006 - 2025 JoomlaWorks Ltd.
JoomlaWorks Ltd. and this site is not affiliated with or endorsed by The Joomla! Project™. Any products and services provided through this site are not supported or warrantied by The Joomla! Project or Open Source Matters, Inc. Use of the Joomla!® name, symbol, logo and related trademarks is permitted under a limited license granted by Open Source Matters, Inc.
designed by Nuevvo