Installing APC on CentOS 5 Server

Collapse
X
Collapse
 

  • Floris
    started a blog post Installing APC on CentOS 5 Server

    Installing APC on CentOS 5 Server

    Bigger PHP applications, such as vBulletin can gain a lot of increased performance from running a PHP op-code cache/accelerator such as APC.

    Here are some instructions on how install APC on various systems, my personal experience is with what appears the most common: 32bit CentOS 5 Server.

    APC is maintained by core PHP developers, APC does not utilze a disk cache, unlike both eAccelerator and Xcache (although it is probably configurable). URL: http://pecl.php.net/package/APC

    A drawback to consider is that due to known segfaults you could get an increase in error 500 or blank pages.

    vBulletin 3.7 RC4 came with this in the announcement: "We recommend that vBulletin 3.7 is run on PHP 5.2.5 with APC (or a similar opcode cache) and MySQL 5.0.51 for best performance and stability."

    Here are some instructions on how install APC on various systems and how to let vBulletin take use of it. My personal experience is with what appears the most common: 32bit CentOS 5 Server

    Please note, due to installed control panels installation instructions might differ, this is for a dedicated box with no control panel.

    Lets first install the pecl command so we can later download and install APC from the repositories.
    Code:
    yum install php-pear
    and we will need the following package
    Code:
    yum install php-devel
    and we probably need the apxs command
    Code:
    yum install httpd-devel
    Now we have all the software we need, so we install apc via the pecl command:
    Code:
    pecl install apc
    To enable apc in Apache's configuration. The following command should do this for us.
    Code:
    echo "extension=apc.so" > /etc/php.d/apc.ini
    Then we restart Apache:
    Code:
    /etc/init.d/httpd start
    (though: service httpd restart should work too)
    You can find out if APC is now running by loading a phpinfo() page (vBulletin AdminCP > Maintenance > phpinfo) and search for APC block.

    Now that it works, go into the includes/config.php file and enable the datastore class to use APC:
    Find:
    Code:
    // $config['Datastore']['class'] = 'vB_Datastore_Filecache';
    and replace it with
    Code:
    $config['Datastore']['class'] = 'vB_Datastore_APC';
    Still in the config.php file you will now find (from 3.7.1 and up) the following option:
    Code:
    // $config['Datastore']['prefix'] = '';
    I recommend to change this if you have multiple forums running on the same box. Since each of my forums uses a unique table prefix based on the domain name, I am using this table prefix for the datastore APC prefix too. Example; my web site vbulletin-fans.com is vbfans_ as table prefix. So I will use this for this instance:
    Code:
    $config['Datastore']['prefix'] = 'vbfans_';
    Keep this as simple and short as possible, but unique.

    To test if it works your PEAR/APC should have come with a file called apc.php. You can now copy this to your vBulletin's directory and edit the file. Set a new user/pass for authentication and load the file in your browser. When you're done you can remove the apc.php file from this public dir.

    And you're done.

    I hope this helps some site owners to get a bit more performance out of their vBulletin powered community and give their visitors a more snappy experience. Note that 3.7 support APC but it works just as well without it. Hopefully in the future (say version 4 and up) vBulletin will make more and better use of op-cache like APC.

    • FractalizeR
      #2
      FractalizeR commented
      Editing a comment
      I am using Apache in worker MPM with latest APC and no segfaults and HTTP 500 errors happen. No at all!

    • Hemanth
      #3
      Hemanth commented
      Editing a comment
      I installed APC and now getting a 404 error in all forum pages. when i disabled apc it went back normal. any suggestions?

      Apache v2.2.11 (cgi)
      PHP: 5.2.8

    • Yves R.
      #4
      Yves R. commented
      Editing a comment
      With PHP 5.3, APC 3.0.x will fail when compiling ( http://pecl.php.net/bugs/bug.php?id=16078 ), use this command instead:
      Code:
      pecl install apc-beta
      This will use APC 3.1.3p1 instead of APC 3.0.19 and all works.
    Posting comments is disabled.

Related Topics

Collapse

Working...