Things a Chameleon Would Say
Web design
There can be several issues when installing APC on a CentOS based operating system with PHP 5.3.2. These include a duplicate ‘static’ error in the zif_apc_compile_file function and some apc_regex errors. This post outlines how to resolve these issues. The complete solution is at the bottom of the post.
I’ve just recently had the opportunity to work with Amazon’s cloud services. As a newcomer to Amazon’s services, I was a bit skeptical; Amazon is, after all, an online retailer. After a few hours working on the server and reading up on Amazon Elastic Compute Cloud (Amazon EC2), my mind was changed. The server is blazing fast and so is its Internet connection.
The machine we’ve got has an operating system based off of CentOS running on it. If I had my way, I’d only ever use Debian-based operating systems and if I could get away with it I’d just plop versions of Ubuntu on servers and get rolling. It’s probably a good thing I’m not a server administrator. Anyway, I ran into some issues installing the Alternative PHP Cache (APC) on this machine. If you don’t want to read all my anecdotes, go to the solution.
The first commands I ran were:
sudo yum install php-pear
sudo yum install php-devel
sudo yum install httpd-devel
sudo pecl install apc
The zeroth issue I ran into was that the server didn’t have a c compiler and the APC install couldn’t complete. A simple install of gcc solved this issue:
sudo yum install gcc
So, then I tried sudo pecl install apc again and the first issue I ran into was an error like this:
/var/tmp/APC/php_apc.c: In function 'zif_apc_compile_file':
/var/tmp/APC/php_apc.c:881: warning: unused variable 'eg_class_table'
/var/tmp/APC/php_apc.c:881: warning: unused variable 'eg_function_table'
/var/tmp/APC/php_apc.c: At top level:
/var/tmp/APC/php_apc.c:959: error: duplicate 'static'
make: *** [php_apc.lo] Error 1
ERROR: `make' failed
Because I’m stubborn, I went ahead and added the apc.so extension in my php configuration hoping that the error didn’t mean anything and that APC succesfully installed anyway:
sudo touch /etc/php.d/apc.ini
This code places a file called apc.ini in the directory that php checks for configuration files while it is loading.
I then put this line into /etc/php.d/apc.ini:
extension=apc.so
While APC still didn’t work, I didn’t have to do this step later.
I continued trying to install APC through different ways: from yum, from source, from pear, and from pecl. I finally got further in the installation process using the command: sudo pecl install apc-beta Notice that I said, “Further in the installation process,” not, “all the way through the installation process.”
The second issue I ran into was an error like this:
In file included from /usr/local/src/APC-3.1.2/apc.c:38:
/usr/include/php/ext/pcre/php_pcre.h:29:18: error: pcre.h: No such file or directory
In file included from /usr/local/src/APC-3.1.2/apc.c:38:
/usr/include/php/ext/pcre/php_pcre.h:45: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
/usr/include/php/ext/pcre/php_pcre.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'
/usr/local/src/APC-3.1.2/apc.c:362: error: expected specifier-qualifier-list before 'pcre'
/usr/local/src/APC-3.1.2/apc.c: In function 'apc_regex_compile_array':
/usr/local/src/APC-3.1.2/apc.c:419: error: 'apc_regex' has no member named 'preg'
/usr/local/src/APC-3.1.2/apc.c:419: error: 'apc_regex' has no member named 'preg'
/usr/local/src/APC-3.1.2/apc.c:420: error: 'apc_regex' has no member named 'nreg'
/usr/local/src/APC-3.1.2/apc.c:420: error: 'apc_regex' has no member named 'nreg'
/usr/local/src/APC-3.1.2/apc.c: In function 'apc_regex_match_array':
/usr/local/src/APC-3.1.2/apc.c:452: error: 'apc_regex' has no member named 'preg'
/usr/local/src/APC-3.1.2/apc.c:452: error: 'apc_regex' has no member named 'preg'
/usr/local/src/APC-3.1.2/apc.c:453: error: 'apc_regex' has no member named 'nreg'
/usr/local/src/APC-3.1.2/apc.c:453: error: 'apc_regex' has no member named 'nreg'
make: *** [apc.lo] Error 1
What you need in this instance is the pcre-devel package: sudo yum install pcre-devel
Complete Solution
In short, this is what you need to run to get APC installed (gcc install only required if you don’t have a C compiler):
sudo yum install php-pear
sudo yum install php-devel
sudo yum install httpd-devel
sudo yum install gcc
sudo yum install pcre-devel
sudo pecl install apc-beta
Then add extension=apc.so to your php.ini file or a config file such as apc.ini inside the php.d/ directory.
Many thanks to various and sundry bloggers who helped me on the way including LONGVNIT who really came through in the clutch with the pcre-devel package suggestion.
11 Responses to “Installing APC on CentOS 5”
Leave a Reply
Have a Question? Need a Quote?
Drop us a line or give us a call at 888-856-2664
What Our Clients Are Saying
To all young App Developers and even the old ones, my partner & I who have no programming experience had a couple of app concepts in mind...went on a little mission to see if someone could develop our ideas. Hearing nothing but horror story's about people spending lots money with no results had us a little nervous. Luckily, we were more than pleasantly surprised when we came across Accella. They are always available when you try to reach them, they explain things in "Laymen" terms for those of us who need it, and work with the utmost integrity. Never in my wildest dreams could I have ever imagined meeting pros like these guys! If your looking for someone to build your app look no further! Accella rocks!
Pete CarrollApp Necessities Text Hold'em & Shake On It
Recent Posts
No More Phone Numbers in Google Ads!
Google has recently updated some of their policies. One big change that m...
South By Southwest App Roundup
Every spring, thousands of people flock to Austin, Texas for South By South...

Finally, at least someone on the interwebs could help me with this stubborn APC install!
have u installed php 5.3.2 on CentOS urself? if so, how?
Thanx for sharing this information.
thanx!
Thanks for this a lot!! I’m sure it will help a LOT of people like it did me. I was stuck after it kept complaining about the preg/nreg, but luckily this saved me with the pcre-devel install.
Thanks so much for this!!
works like a champ. I fiddled around for 2 hours until i found this post. Worked perfectly, APC is running on my site, performance is significantly improved.
thx,
p
thanks, this helped me a lot !
Thanks, same problem same solution.
Hey man. thanks for your help.
[...] function and some apc_regex errors. This post outlines how to resolve these issues. The complete solution is at the bottom of the [...]
Thx man ! i’ve been looking for about 2 days…
HI,
Great advice.. even better when I read as far as the solution you finally found.
Can I suggest removing the console lines from above that lead to the failure.. I suspect that many will do as I did and C&P the non-working lines in.
Luckily I kept on reading and found the working solution – all credit to you for that!
Thanks