How to Fix APC Installation Error on Ubuntu

The Alternative PHP Cache (APC) is a free and open opcode cache for PHP.

Its goal is to provide a free, open, and robust framework for caching and optimizing PHP intermediate code.

Installation of APC is quite simple.

This article shows you how to fix APC installation problem when it fails at make process as following:


In file included from /tmp/pear/temp/APC/apc.c:44:
/usr/include/php5/ext/pcre/php_pcre.h:29:18: error: pcre.h: No such file or directory
In file included from /tmp/pear/temp/APC/apc.c:44:
/usr/include/php5/ext/pcre/php_pcre.h:37: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
/usr/include/php5/ext/pcre/php_pcre.h:38: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
/usr/include/php5/ext/pcre/php_pcre.h:44: error: expected specifier-qualifier-list before ‘pcre’
/tmp/pear/temp/APC/apc.c:393: error: expected specifier-qualifier-list before ‘pcre’
/tmp/pear/temp/APC/apc.c: In function ‘apc_regex_compile_array’:
/tmp/pear/temp/APC/apc.c:454: error: ‘apc_regex’ has no member named ‘preg’
/tmp/pear/temp/APC/apc.c:454: error: ‘apc_regex’ has no member named ‘preg’
/tmp/pear/temp/APC/apc.c:455: error: ‘apc_regex’ has no member named ‘nreg’
/tmp/pear/temp/APC/apc.c:455: error: ‘apc_regex’ has no member named ‘nreg’
/tmp/pear/temp/APC/apc.c: In function ‘apc_regex_match_array’:
/tmp/pear/temp/APC/apc.c:487: error: ‘apc_regex’ has no member named ‘preg’
/tmp/pear/temp/APC/apc.c:487: error: ‘apc_regex’ has no member named ‘preg’
/tmp/pear/temp/APC/apc.c:488: error: ‘apc_regex’ has no member named ‘nreg’
/tmp/pear/temp/APC/apc.c:488: error: ‘apc_regex’ has no member named ‘nreg’
make: *** [apc.lo] Error 1
ERROR: `make' failed

To fix the problem, you have to install libpcre3-dev package.

Run this command:


$ sudo apt-get install libpcre3-dev

After that, redo the installation and the problem will gone:


$ sudo pecl install apc

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.