Installing PHP APC On RHEL/CentOS

  1. Yum up some packages:
    yum install php-pear php-devel httpd-devel
  2. Install APC using pear (the pear installer is smarter than the pecl installer):
    When the installer asks about APXS, say ‘no’. 

    pear install pecl/apc
  3. Tell PHP to load APC:
    echo extension=apc.so > /etc/php.d/apc.ini
  4. Restart Apache:
    /sbin/service httpd graceful

13 Responses to “Installing PHP APC On RHEL/CentOS”

  1. Thanks. Very simple, very clear, very complete directions. Are you sure you are a linux guy? They are going to revoke your group membership privileges if you don’t make these directions either partially incomplete or somewhat arcane.

  2. @Mark:

    Thanks, but don’t worry for me. These directions will become incomplete and misleading as soon as the underlying OS changes.

  3. Many thanks. I agree with Mark. After seeing so many ridiculously complicated explanations of the above simple process I can only say again – thank you for you help and effort.

  4. Hi Casey,
    Can you explain why you choose “no” for APXS?

    Thanks,
    -mike

  5. Very clear.
    Good job.

  6. @Mike: Because there had to be at least one unexplained, obscure thing in a Linux related post?

    Casey, I’d love to know the answer to Mike’s question as well. Did testing having answered ‘yes’ reveal subtle weirdness? Did things blow up spectacularly? Or does that let you avoid pulling in httpd-devel and all the compiler-related dependencies that that brings in?

    Cheers (and add my thanks to the list!),

    Justin

    • @Justin:

      My first few tries were with APXS, but they failed (can’t remember errors). It didn’t blow up so bad that I couldn’t try again, it just didn’t work.

  7. I had to add the line below to my php.ini to get APC to load on RHEL with PHP 5.2.

    apc.rfc1867 = 1

  8. The first command should be

    yum install php-pear php-devel httpd-devel pcre-devel

  9. I couldnt get this working sadly, APC does not show up on my PHP 5.1.6

    Ive tried adding enable=apc.so to my /etc/php.d/apc.ini and when that didnt work to my /etc/php.ini

    Not quite sure whats up but if I figure it out Ill post more.

  10. When I try to Run the below Command it GIves an Error as Follows;
    Suggest me the to FIX this Issue;

    ———————————————————————————————————————–
    [root@ns1 ~]# pear install pecl/apc
    downloading APC-3.1.6.tgz …
    Starting to download APC-3.1.6.tgz (148,835 bytes)
    ……………………………done: 148,835 bytes
    49 source files, building
    running: phpize
    Configuring for:
    PHP Api Version: 20041225
    Zend Module Api No: 20050922
    Zend Extension Api No: 220051025
    /usr/bin/phpize: /tmp/tmpMLjpYV/APC-3.1.6/build/shtool: /bin/sh: bad interpreter: Permission denied
    Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF
    environment variable is set correctly and then rerun this script.

    ERROR: `phpize’ failed
    ———————————————————————————————————————–

    How to Resolve this..

Trackbacks

User contributed tags for this post: