I assume you already have PEAR/PECL available. I am using the CentOS’s stock PHP. First you need to update your channels:

[code lang=“bash”]kahwee:~ kahwee$ sudo pear update-channels

Updating channel “doc.php.net”

Channel “doc.php.net” is up to date

Updating channel “pear.php.net”

Channel “pear.php.net” is up to date

Updating channel “pecl.php.net”

Channel “pecl.php.net” is up to date[/code]

[code lang=“bash”]kahwee:~ kahwee$ sudo pecl install apc

….done: 148,835 bytes

49 source files, building

…[/code]

If you get an error like the following:

[code lang=“bash”]…

In file included from /var/tmp/APC/apc.c:44:

/usr/include/php/ext/pcre/phppcre.h:45: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘’ token

/usr/include/php/ext/pcre/phppcre.h:46: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘’ token

/usr/include/php/ext/pcre/php_pcre.h:52: error: expected specifier-qualifier-list before ‘pcre’

/var/tmp/APC/apc.c:393: error: expected specifier-qualifier-list before ‘pcre’

/var/tmp/APC/apc.c: In function ‘apc_regex_compile_array’:

/var/tmp/APC/apc.c:454: error: ‘apc_regex’ has no member named ‘preg’

/var/tmp/APC/apc.c:454: error: ‘apc_regex’ has no member named ‘preg’

/var/tmp/APC/apc.c:455: error: ‘apc_regex’ has no member named ‘nreg’

/var/tmp/APC/apc.c:455: error: ‘apc_regex’ has no member named ‘nreg’

/var/tmp/APC/apc.c: In function ‘apc_regex_match_array’:

/var/tmp/APC/apc.c:487: error: ‘apc_regex’ has no member named ‘preg’

/var/tmp/APC/apc.c:487: error: ‘apc_regex’ has no member named ‘preg’

/var/tmp/APC/apc.c:488: error: ‘apc_regex’ has no member named ‘nreg’

/var/tmp/APC/apc.c:488: error: ‘apc_regex’ has no member named ‘nreg’

…[/code]

…it is because you do not have PCRE library headers. We can install that with yum:

[code lang=“bash”]sudo yum install pcre-devel[/code]

After installing that, you should be able to successfully complete the PHP APC installation:

[code lang=“bash”]kahwee:~ kahwee$ sudo pecl install apc

Build process completed successfully

You should add “extension=apc.so” to php.ini[/code]

Finally, you can add “extension=apc.so” to your PHP’s configuration.

[code lang=“bash”]nano /etc/php.d/apc.ini[/code]

I also added the following settings in /etc/php.d/apc.ini:

[code lang=“bash”]extension=apc.so

apc.enabled=1

apc.shm_segments=1

apc.shm_size=32M

apc.cache_by_default=1

apc.stat=1

apc.rfc1867=1 //For Drupal upload progress.

apc.stat=7200 //2 hours[/code]

And finally to restart Apache:

[code lang=“bash”]/etc/init.d/httpd restart[/code]

So to summarize, here’s what I did:

[code lang=“bash”]sudo yum install php-devel

sudo yum install httpd-devel

sudo yum install pcre-devel

sudo pecl install apc[/code]

Remember to

[code lang=“bash”]/etc/init.d/httpd restart[/code]

This should work for Red Hat Linux too.

comments powered by Disqus