JoomlaWorks

  • Extension Demos
  • Community Forum
  • K2
  • JoomlaReader
login

  • Forgot your password?
  • Home
  • About
    • Company
    • License & Terms of Service
  • Extensions
    • Commercial Premium
      • Frontpage Slideshow
      • K2mart
      • Simple Image Gallery Pro
      • SocialConnect
      • SuperBlogger
    • Free Premium
      • AllVideos
      • DISQUS Comments for Joomla! (package)
      • K2
      • Simple Image Gallery
      • Simple RSS Feed Reader
      • Tabs & Sliders [for articles] (plugin)
      • Tabs & Sliders (module)
      • Ultimate Content Display
    • Free
      • Latest Tweets
      • TinyLetter Subscribe
      • User Extended Fields for K2
  • Docs
    • AllVideos
    • Frontpage Slideshow
    • Frontpage Slideshow [Standalone]
    • K2mart
    • Simple Image Gallery
    • Simple Image Gallery Pro
    • SocialConnect
    • SuperBlogger
    • Tabs & Sliders (module)
  • Blog
  • Contact
  • My Account
01 12 2010
Written by  Fotis Evangelou
Published in Blog
Tagged under
  • +apc
  • +cache
  • +joomla
  • +Performance
  • +session
20 comments

Install APC on a WHM/cPanel server (11.28+) the easy way and boost Joomla! performance!

Install APC on a WHM/cPanel server (11.28+) the easy way and boost Joomla! performance!
If you run a popular Joomla! website on a powerful VPS or even dedicated server 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 another lengthy post, I thought I'd just write a couple of words on improving one aspect of Joomla!'s performance quickly and efficiently: PHP execution by using the APC opcode caching module.

There are many tutorials out there covering how to install APC from command line (as root user), but none on how to install APC 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 APC 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 faster than mod_php.

Assuming you have PHP in FastCGI mode running on your WHM/cPanel (version 11.28+) based server, there are 3 simple steps to install APC on your server:

1. Login as "root" user via SSH and run this command:

yum install pcre-devel

This will install some required dependencies for the next steps...


2. Login to WHM and navigate to "Service Configuration" >> "PHP Configuration Editor", then "Switch to Advanced Mode" and change under section "Core" and command "extension_dir" the PHP extensions path from "/usr/local/lib/php/extensions/no-debug-non-zts-200XXXXX" to "/usr/lib/php/extensions/no-debug-non-zts-200XXXXX". 200XXXXX depends on the PHP version installed on your server. If it's PHP 5.2 you'll see 2006XXXX, if it's PHP 5.3 you'll see 2009XXXX. Save and restart Apache.

IMPORTANT: If the above change causes problems on your server, that may occur because you already have other PHP extensions that use the default cPanel PHP extensions install location. In that case, simply create a "symlink" (a shortcut) of "/usr/local/lib/php/extensions/no-debug-non-zts-200XXXXX" to "/usr/lib/php/extensions/no-debug-non-zts-200XXXXX". Do that by executing the following via SSH as root user:

ln -s /usr/local/lib/php/extensions/no-debug-non-zts-200XXXXX /usr/lib/php/extensions/no-debug-non-zts-200XXXXX

Don't forget to change 200XXXXX to your actual system folder.

The above shortcut will just copy any future PHP extensions to the cPanel default directory for installed PHP extensions.


3. Still logged in on WHM, navigate to "Software" >> "Module Installers" then click on "manage" next to  "PHP Pecl", search for "APC" in "Find a PHP Pecl" and then choose to "Install" in the APC result that will come up.

That's it!

Now, if you wanna make use of APC on your Joomla! 1.5/1.7 site, go to "Global Configuration" and choose to use "Apc" instead of "File" for the cache setting. Using "Apc" instead of "Database" for the sessions didn't work for me in Joomla! 1.5 last time I checked. Perhaps it now works with 1.7+.

You may also wish to tweak "apc.shm_size" in PHP's configuration and raise this limit from 32 (MBs) to 64 or 128 depending on your server's capabilities. For very busy sites, you may want to consider switching off "apc.slam_defense" and "apc.stat". For more on APC's configuration options, visit: http://php.net/manual/en/apc.configuration.php

UPDATE: APC provides a detailed look at what is happening with your cache and, with GD enabled in PHP, also shows you graphs of the situation of your cache. And all this via your browser! After you follow the steps above and install APC successfully, copy the file /usr/lib/php/apc.php into your website's "live" path and access it via the browser. Just remember to change permissions of apc.php to the user whose website you're moving the script in.

Apc_dashboard
Read 86636 times
Tweet
More in this category: « Elegant way to pass on your primary Joomla! RSS feed to Feedburner So what's it gonna be Ning? Are you gonna deal with spam seriously or not? »

20 comments

  • Fotis Evangelou Fotis Evangelou 23 Mar 2012
    Comment Link


    APC is a PHP extension and I assume it should not conflict in any way with Litespeed. Litespeed is supposed to be fully compatible with whatever Apache is compatible with. If your setup works for you, there's no need to switch to Apache...

  • OpenPotion OpenPotion 23 Mar 2012
    Comment Link


    Ok one more... My server is using Litespeed rather than Apache and APC. And I am setting up clients joomla sites to cache with APC. Do you recommend I scrap litespeed, use apache, and switch to FastCGI? Or can I use Litespeed, APC, and FastCGI? My head is spinning...thoughts my Joomla guru?

  • Fotis Evangelou Fotis Evangelou 22 Mar 2012
    Comment Link


    Symbolic links (symlinks) are just shortcuts. So you can safely delete them.

  • OpenPotion OpenPotion 21 Mar 2012
    Comment Link


    How do you undo that symbolic link if needed?

  • Fotis Evangelou Fotis Evangelou 21 Mar 2012
    Comment Link


    @gswahhab Kinda late to reply (hadn't noticed all comments for some reason via the old Posterous backend) but APC does opcode caching as well, indifferent to Joomla's caching. So it does speedup things a bit. If you install the apc.php file I mention above, you'll have a better overview of what APC does for your site. For the record, getk2.org runs fully on APC without page caching ;)

  • Fotis Evangelou Fotis Evangelou 21 Mar 2012
    Comment Link


    @OpenPotion
    1. APC is natively supported by Joomla! unlike XCache and eAccelerator.
    2. To use APC successfully, you need to have cPanel "rebuilt" using FastCGI mode. Adding XCache or eAccelerator makes no difference as they won't be used either way.
    3. Installation is done via the cPanel PECL manager. So is uninstallation. If you don't want PHP to "see" APC, simply navigate to "Service Configuration" >> "PHP Configuration Editor", then "Switch to Advanced Mode" and under section "Core" and ABOVE the command "extension_dir", locate in the input field on the right "apc.so" and simply delete it. This prevents PHP from loading the APC extension.
    4. Symlinks are fine.

  • OpenPotion OpenPotion 21 Mar 2012
    Comment Link


    is your symbolic link command code backwards?

  • OpenPotion OpenPotion 21 Mar 2012
    Comment Link


    and should eAccelerator be disabled?

  • OpenPotion OpenPotion 21 Mar 2012
    Comment Link


    Uninstall directions might be nice in case people want to revert due to issues?

  • OpenPotion OpenPotion 21 Mar 2012
    Comment Link


    What about this thing called xcache I see in EasyApache? Any good? Any things that should be disabled that conflict with APC?

  • Fotis Evangelou Fotis Evangelou 16 Dec 2011
    Comment Link


    @wooo77 Using FastCGI will surely make your server perform better but there is one drawback out of the box: You cannot have custom php.ini files per domain or folder, unless you setup FastCGI to parse them explicitly. An easy solution is to install HTscanner, a PECL plugin like APC, which allows FastCGI servers to have php_flag values inside .htaccess or other custom-name files.

  • woood77 woood77 16 Dec 2011
    Comment Link


    Hello,

    I've been considering this for a while but I don't have much experience with the different php handlers.

    I'm currently running about 200 joomla sites on a single WHM/cPanel server. The average site receives roughly 100 unique visits per day. The server is currently running suPHP as that is what my host recommended for security reasons.

    Would you recommend fastcgi and the apc module based on my configuration and would you consider it as secure as suPHP?

    Thanks guys


  • woood77 woood77 16 Dec 2011
    Comment Link


    Hello,

    I've been considering this myself however I'm not very experienced in the different php handlers.

    I currently have about 200 joomla sites running on a single server. The average site traffic is probably 100 unique hits a day. The server is configured using suPHP for security reasons as that is what my host recommended.

    Would you still recommend fastcgi and the apc module for a configuration like mine and would you say it is as secure as suPHP?

    Thanks guys


  • Fotis Evangelou Fotis Evangelou 16 Dec 2011
    Comment Link


    I've revised my article with some extra info to help you guys out.

  • genesteinberg genesteinberg 25 Nov 2011
    Comment Link


    Nice information, but the installation fails in my installation because the cPanel installer cannot seem to find the apc.so file in the proper directory.

    The default directory is /usr/local/lib/php/extensions/no-debug-non-zts-20090626, and the /usr/lib/ etc., equivalent doesn't help.

    I've asked cPanel to figure it out, since they provide the installer capability. But do you have an alternatives to suggest if it doesn't work.

    Peace,
    Gene Steinberg


  • weltlighting weltlighting 24 Nov 2011
    Comment Link


    the problem is that if i modify the path from /usr/local/lib/php/extensions/no-debug-non-zts-20060613" to "/usr/lib/php/extensions/no-debug-non-zts-20060613 my website is not working, but apc.php is showing me the graphs, if i change it back to /usr/local/lib/php/extensions/no-debug-non-zts-20060613 the website is working fine but apc doesn't....any idea??

  • weltlighting weltlighting 24 Nov 2011
    Comment Link


    hi, amazing tutorial 3 easy steps.

    I have the apc.php file on my server but when i access it it says

    No cache info available. APC does not appear to be running.

    any idea?


  • 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.

Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

back to top
BY MAIL BY RSS

Archives

  • March 2013 (1)
  • February 2013 (1)
  • September 2012 (1)
  • August 2012 (1)
  • October 2011 (1)
  • July 2011 (1)
  • June 2011 (1)
  • May 2011 (1)
  • April 2011 (2)
  • March 2011 (2)
  • February 2011 (2)
  • January 2011 (1)

Tag Cloud

1.6 alex kempkens athens centos component cpanel event fotis evangelou greece jab10 j and beyond johan janssens joomla joomladay k2 max milbers nooku pecl presentation video

Fresh from our Blog!

  • 07 Mar 2013 Simple Image Gallery Pro version 3 and a new design approach for our components
    Written by Fotis Evangelou
  • 19 Feb 2013 SocialConnect - a new Joomla! extension for better social reach & user engagement
    Written by Fotis Evangelou
  • 09 Sep 2012 Resizing the disk space on Ubuntu Server VMs running on VMware ESXi 5
    Written by Fotis Evangelou
  • 16 Aug 2012 How to create a zip file of all Google Web Fonts on a Mac
    Written by Fotis Evangelou
  • 01 Oct 2011 Joomla! forks you may have never heard of
    Written by Fotis Evangelou

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
  • YouTube
  • Facebook
  • Twitpic
  • Google+
  • Speaker Deck
  • Google Code Project

Grab Our Feeds

  • Extension Updates
  • Blog
  • Videos
  • Presentations
Copyright © 2006 - 2013 JoomlaWorks Ltd.
Joomla! is a registered trademark of Open Source Matters, Inc. JoomlaWorks Ltd. is not affiliated with or endorsed by Open Source Matters or the Joomla! Project.
designed by Nuevvo