Manually install stable version of APC in CentOS

Horse stable with a single horse at the end of the aisle.
The famous Mr. Ed. In a stable.

First you’ll want to make sure you have all required packages installed:

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

Most tutorials will now say to use PECL to install APC:

[root@vps ~]# pecl install apc
downloading APC-3.1.13.tgz ...
Starting to download APC-3.1.13.tgz (171,591 bytes)

But that actually installs the latest version, even if it’s in beta (in this case it is), so we’ll actually manually download and install it.

Download APC

You can go and look up the latest, stable version here: http://pecl.php.net/package/APC. Once you find it, which happens to be APC 3.1.9 at this time, copy the link in the downloads column and download it:

[root@vps ~]# wget http://pecl.php.net/get/APC-3.1.9.tgz
--2013-08-04 08:35:58--  http://pecl.php.net/get/APC-3.1.9.tgz
Resolving pecl.php.net... 76.75.200.106
Connecting to pecl.php.net|76.75.200.106|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 155540 (152K) [application/octet-stream]
Saving to: `APC-3.1.9.tgz'

100%[================================================================================================================================>] 155,540      537K/s   in 0.3s    

2013-08-04 08:35:59 (537 KB/s) - `APC-3.1.9.tgz' saved [155540/155540]

Extract APC

After it has downloaded, we extract the archive file and move into the newly created directory:

tar -zxf APC-3.1.9.tgz
cd APC-3.1.9

Compile APC with phpize

Next we’ll compile the extension using phpize:

[root@vps APC-3.1.9]# phpize
Configuring for:
PHP Api Version:         20041225
Zend Module Api No:      20050922
Zend Extension Api No:   220051025

Configure APC with php-config

We will need to look up where your php-config lives (most likely /usr/bin/php-config):

[root@vps APC-3.1.9]# whereis php-config
php-config: /usr/bin/php-config /usr/share/man/man1/php-config.1.gz

Next we’ll configure the extension. Note to update the path, should it differ, at the very end of the first line:

[root@vps APC-3.1.9]# ./configure --enable-apc --enable-apc-mmap --with-apxs --with-php-config=/usr/bin/php-config
checking for egrep... grep -E
checking for a sed that does not truncate output... /bin/sed
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking whether gcc and cc understand -c and -o together... yes
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-redhat-linux-gnu
checking host system type... x86_64-redhat-linux-gnu
checking target system type... x86_64-redhat-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext
checking for PHP extension directory... /usr/lib64/php/modules
checking for PHP installed headers prefix... /usr/include/php
checking for re2c... no
configure: WARNING: You will need re2c 0.9.11 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking whether to enable APC support... yes, shared
checking whether we should enable cache request file info... no
checking whether we should use mmap... yes
checking whether we should use semaphore locking instead of fcntl... no
checking whether we should use pthread mutex locking... yes
pthread mutexs are supported!
checking whether we should use pthread read/write locking... no
checking whether the target compiler supports builtin atomics... yes
checking whether we should use spin locks... no
checking whether we should enable memory protection... no
checking for zend_set_lookup_function_hook... no
checking for sigaction... yes
checking for union semun... no
checking whether we should enable valgrind support... checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
yes
checking valgrind/memcheck.h usability... no
checking valgrind/memcheck.h presence... no
checking for valgrind/memcheck.h... no
checking for shm_open in -lrt... yes
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for /usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -B
checking whether ln -s works... yes
checking how to recognise dependent libraries... pass_all
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking for g++... no
checking for c++... no
checking for gpp... no
checking for aCC... no
checking for CC... no
checking for cxx... no
checking for cc++... no
checking for cl... no
checking for FCC... no
checking for KCC... no
checking for RCC... no
checking for xlC_r... no
checking for xlC... no
checking whether we are using the GNU C++ compiler... no
checking whether g++ accepts -g... no
checking for g77... no
checking for f77... no
checking for xlf... no
checking for frt... no
checking for pgf77... no
checking for fort77... no
checking for fl32... no
checking for af77... no
checking for f90... no
checking for xlf90... no
checking for pgf90... no
checking for epcf90... no
checking for f95... no
checking for fort... no
checking for xlf95... no
checking for ifc... no
checking for efc... no
checking for pgf95... no
checking for lf95... no
checking for gfortran... no
checking whether we are using the GNU Fortran 77 compiler... no
checking whether  accepts -g... no
checking the maximum length of command line arguments... 32768
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC
checking if gcc PIC flag -fPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
configure: creating libtool
appending configuration tag "CXX" to libtool
appending configuration tag "F77" to libtool
configure: creating ./config.status
config.status: creating config.h

Recompile APC with make

Now we need to recompile the extension using make:

[root@vps APC-3.1.9]# make install
/bin/sh /root/APC-3.1.9/libtool --mode=compile gcc  -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext  -DHAVE_CONFIG_H  -g -O2   -c /root/APC-3.1.9/apc.c -o apc.lo 
mkdir .libs
 gcc -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -DHAVE_CONFIG_H -g -O2 -c /root/APC-3.1.9/apc.c  -fPIC -DPIC -o .libs/apc.o
/bin/sh /root/APC-3.1.9/libtool --mode=compile gcc  -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext  -DHAVE_CONFIG_H  -g -O2   -c /root/APC-3.1.9/php_apc.c -o php_apc.lo 
 gcc -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -DHAVE_CONFIG_H -g -O2 -c /root/APC-3.1.9/php_apc.c  -fPIC -DPIC -o .libs/php_apc.o
/bin/sh /root/APC-3.1.9/libtool --mode=compile gcc  -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext  -DHAVE_CONFIG_H  -g -O2   -c /root/APC-3.1.9/apc_cache.c -o apc_cache.lo 
 gcc -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -DHAVE_CONFIG_H -g -O2 -c /root/APC-3.1.9/apc_cache.c  -fPIC -DPIC -o .libs/apc_cache.o
/root/APC-3.1.9/apc_cache.c: In function 'apc_cache_make_file_key':
/root/APC-3.1.9/apc_cache.c:950: warning: passing argument 1 of 'zend_inline_hash_func' discards qualifiers from pointer target type
/root/APC-3.1.9/apc_cache.c:970: warning: passing argument 1 of 'zend_inline_hash_func' discards qualifiers from pointer target type
/root/APC-3.1.9/apc_cache.c: In function 'apc_cache_make_user_key':
/root/APC-3.1.9/apc_cache.c:1067: warning: passing argument 1 of 'zend_inline_hash_func' discards qualifiers from pointer target type
/bin/sh /root/APC-3.1.9/libtool --mode=compile gcc  -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext  -DHAVE_CONFIG_H  -g -O2   -c /root/APC-3.1.9/apc_compile.c -o apc_compile.lo 
 gcc -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -DHAVE_CONFIG_H -g -O2 -c /root/APC-3.1.9/apc_compile.c  -fPIC -DPIC -o .libs/apc_compile.o
/root/APC-3.1.9/apc_compile.c:293: warning: 'hot' attribute directive ignored
/root/APC-3.1.9/apc_compile.c:842: warning: 'hot' attribute directive ignored
/root/APC-3.1.9/apc_compile.c: In function 'apc_file_halt_offset':
/root/APC-3.1.9/apc_compile.c:1855: warning: passing argument 5 of 'zend_mangle_property_name' discards qualifiers from pointer target type
/root/APC-3.1.9/apc_compile.c: In function 'apc_do_halt_compiler_register':
/root/APC-3.1.9/apc_compile.c:1877: warning: passing argument 5 of 'zend_mangle_property_name' discards qualifiers from pointer target type
/bin/sh /root/APC-3.1.9/libtool --mode=compile gcc  -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext  -DHAVE_CONFIG_H  -g -O2   -c /root/APC-3.1.9/apc_debug.c -o apc_debug.lo 
 gcc -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -DHAVE_CONFIG_H -g -O2 -c /root/APC-3.1.9/apc_debug.c  -fPIC -DPIC -o .libs/apc_debug.o
/bin/sh /root/APC-3.1.9/libtool --mode=compile gcc  -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext  -DHAVE_CONFIG_H  -g -O2   -c /root/APC-3.1.9/apc_fcntl.c -o apc_fcntl.lo 
 gcc -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -DHAVE_CONFIG_H -g -O2 -c /root/APC-3.1.9/apc_fcntl.c  -fPIC -DPIC -o .libs/apc_fcntl.o
/bin/sh /root/APC-3.1.9/libtool --mode=compile gcc  -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext  -DHAVE_CONFIG_H  -g -O2   -c /root/APC-3.1.9/apc_main.c -o apc_main.lo 
 gcc -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -DHAVE_CONFIG_H -g -O2 -c /root/APC-3.1.9/apc_main.c  -fPIC -DPIC -o .libs/apc_main.o
/bin/sh /root/APC-3.1.9/libtool --mode=compile gcc  -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext  -DHAVE_CONFIG_H  -g -O2   -c /root/APC-3.1.9/apc_mmap.c -o apc_mmap.lo 
 gcc -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -DHAVE_CONFIG_H -g -O2 -c /root/APC-3.1.9/apc_mmap.c  -fPIC -DPIC -o .libs/apc_mmap.o
/bin/sh /root/APC-3.1.9/libtool --mode=compile gcc  -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext  -DHAVE_CONFIG_H  -g -O2   -c /root/APC-3.1.9/apc_sem.c -o apc_sem.lo 
 gcc -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -DHAVE_CONFIG_H -g -O2 -c /root/APC-3.1.9/apc_sem.c  -fPIC -DPIC -o .libs/apc_sem.o
/bin/sh /root/APC-3.1.9/libtool --mode=compile gcc  -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext  -DHAVE_CONFIG_H  -g -O2   -c /root/APC-3.1.9/apc_shm.c -o apc_shm.lo 
 gcc -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -DHAVE_CONFIG_H -g -O2 -c /root/APC-3.1.9/apc_shm.c  -fPIC -DPIC -o .libs/apc_shm.o
/bin/sh /root/APC-3.1.9/libtool --mode=compile gcc  -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext  -DHAVE_CONFIG_H  -g -O2   -c /root/APC-3.1.9/apc_pthreadmutex.c -o apc_pthreadmutex.lo 
 gcc -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -DHAVE_CONFIG_H -g -O2 -c /root/APC-3.1.9/apc_pthreadmutex.c  -fPIC -DPIC -o .libs/apc_pthreadmutex.o
/bin/sh /root/APC-3.1.9/libtool --mode=compile gcc  -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext  -DHAVE_CONFIG_H  -g -O2   -c /root/APC-3.1.9/apc_pthreadrwlock.c -o apc_pthreadrwlock.lo 
 gcc -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -DHAVE_CONFIG_H -g -O2 -c /root/APC-3.1.9/apc_pthreadrwlock.c  -fPIC -DPIC -o .libs/apc_pthreadrwlock.o
/bin/sh /root/APC-3.1.9/libtool --mode=compile gcc  -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext  -DHAVE_CONFIG_H  -g -O2   -c /root/APC-3.1.9/apc_spin.c -o apc_spin.lo 
 gcc -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -DHAVE_CONFIG_H -g -O2 -c /root/APC-3.1.9/apc_spin.c  -fPIC -DPIC -o .libs/apc_spin.o
/bin/sh /root/APC-3.1.9/libtool --mode=compile gcc  -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext  -DHAVE_CONFIG_H  -g -O2   -c /root/APC-3.1.9/pgsql_s_lock.c -o pgsql_s_lock.lo 
 gcc -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -DHAVE_CONFIG_H -g -O2 -c /root/APC-3.1.9/pgsql_s_lock.c  -fPIC -DPIC -o .libs/pgsql_s_lock.o
/bin/sh /root/APC-3.1.9/libtool --mode=compile gcc  -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext  -DHAVE_CONFIG_H  -g -O2   -c /root/APC-3.1.9/apc_sma.c -o apc_sma.lo 
 gcc -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -DHAVE_CONFIG_H -g -O2 -c /root/APC-3.1.9/apc_sma.c  -fPIC -DPIC -o .libs/apc_sma.o
/root/APC-3.1.9/apc_sma.c:181: warning: 'hot' attribute directive ignored
/root/APC-3.1.9/apc_sma.c:278: warning: 'hot' attribute directive ignored
/bin/sh /root/APC-3.1.9/libtool --mode=compile gcc  -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext  -DHAVE_CONFIG_H  -g -O2   -c /root/APC-3.1.9/apc_stack.c -o apc_stack.lo 
 gcc -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -DHAVE_CONFIG_H -g -O2 -c /root/APC-3.1.9/apc_stack.c  -fPIC -DPIC -o .libs/apc_stack.o
/bin/sh /root/APC-3.1.9/libtool --mode=compile gcc  -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext  -DHAVE_CONFIG_H  -g -O2   -c /root/APC-3.1.9/apc_zend.c -o apc_zend.lo 
 gcc -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -DHAVE_CONFIG_H -g -O2 -c /root/APC-3.1.9/apc_zend.c  -fPIC -DPIC -o .libs/apc_zend.o
/bin/sh /root/APC-3.1.9/libtool --mode=compile gcc  -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext  -DHAVE_CONFIG_H  -g -O2   -c /root/APC-3.1.9/apc_rfc1867.c -o apc_rfc1867.lo 
 gcc -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -DHAVE_CONFIG_H -g -O2 -c /root/APC-3.1.9/apc_rfc1867.c  -fPIC -DPIC -o .libs/apc_rfc1867.o
/bin/sh /root/APC-3.1.9/libtool --mode=compile gcc  -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext  -DHAVE_CONFIG_H  -g -O2   -c /root/APC-3.1.9/apc_signal.c -o apc_signal.lo 
 gcc -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -DHAVE_CONFIG_H -g -O2 -c /root/APC-3.1.9/apc_signal.c  -fPIC -DPIC -o .libs/apc_signal.o
/bin/sh /root/APC-3.1.9/libtool --mode=compile gcc  -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext  -DHAVE_CONFIG_H  -g -O2   -c /root/APC-3.1.9/apc_pool.c -o apc_pool.lo 
 gcc -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -DHAVE_CONFIG_H -g -O2 -c /root/APC-3.1.9/apc_pool.c  -fPIC -DPIC -o .libs/apc_pool.o
/bin/sh /root/APC-3.1.9/libtool --mode=compile gcc  -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext  -DHAVE_CONFIG_H  -g -O2   -c /root/APC-3.1.9/apc_iterator.c -o apc_iterator.lo 
 gcc -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -DHAVE_CONFIG_H -g -O2 -c /root/APC-3.1.9/apc_iterator.c  -fPIC -DPIC -o .libs/apc_iterator.o
/bin/sh /root/APC-3.1.9/libtool --mode=compile gcc  -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext  -DHAVE_CONFIG_H  -g -O2   -c /root/APC-3.1.9/apc_bin.c -o apc_bin.lo 
 gcc -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -DHAVE_CONFIG_H -g -O2 -c /root/APC-3.1.9/apc_bin.c  -fPIC -DPIC -o .libs/apc_bin.o
/bin/sh /root/APC-3.1.9/libtool --mode=compile gcc  -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext  -DHAVE_CONFIG_H  -g -O2   -c /root/APC-3.1.9/apc_string.c -o apc_string.lo 
 gcc -I. -I/root/APC-3.1.9 -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -DHAVE_CONFIG_H -g -O2 -c /root/APC-3.1.9/apc_string.c  -fPIC -DPIC -o .libs/apc_string.o
/bin/sh /root/APC-3.1.9/libtool --mode=link gcc -DPHP_ATOM_INC -I/root/APC-3.1.9/include -I/root/APC-3.1.9/main -I/root/APC-3.1.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext  -DHAVE_CONFIG_H  -g -O2   -o apc.la -export-dynamic -avoid-version -prefer-pic -module -rpath /root/APC-3.1.9/modules  apc.lo php_apc.lo apc_cache.lo apc_compile.lo apc_debug.lo apc_fcntl.lo apc_main.lo apc_mmap.lo apc_sem.lo apc_shm.lo apc_pthreadmutex.lo apc_pthreadrwlock.lo apc_spin.lo pgsql_s_lock.lo apc_sma.lo apc_stack.lo apc_zend.lo apc_rfc1867.lo apc_signal.lo apc_pool.lo apc_iterator.lo apc_bin.lo apc_string.lo -lrt
gcc -shared  .libs/apc.o .libs/php_apc.o .libs/apc_cache.o .libs/apc_compile.o .libs/apc_debug.o .libs/apc_fcntl.o .libs/apc_main.o .libs/apc_mmap.o .libs/apc_sem.o .libs/apc_shm.o .libs/apc_pthreadmutex.o .libs/apc_pthreadrwlock.o .libs/apc_spin.o .libs/pgsql_s_lock.o .libs/apc_sma.o .libs/apc_stack.o .libs/apc_zend.o .libs/apc_rfc1867.o .libs/apc_signal.o .libs/apc_pool.o .libs/apc_iterator.o .libs/apc_bin.o .libs/apc_string.o  -lrt  -Wl,-soname -Wl,apc.so -o .libs/apc.so
creating apc.la
(cd .libs && rm -f apc.la && ln -s ../apc.la apc.la)
/bin/sh /root/APC-3.1.9/libtool --mode=install cp ./apc.la /root/APC-3.1.9/modules
cp ./.libs/apc.so /root/APC-3.1.9/modules/apc.so
cp ./.libs/apc.lai /root/APC-3.1.9/modules/apc.la
PATH="$PATH:/sbin" ldconfig -n /root/APC-3.1.9/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /root/APC-3.1.9/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Installing shared extensions:     /usr/lib64/php/modules/
Installing header files:          /usr/include/php/

Enable APC in PHP

This completes the installation and all we have left to do is set APC up. The next step is to create an ini file in /etc/php.d:

cd /etc/php.d
vi apc.ini

And paste the following into it:

; Enable the extension module
extension=apc.so

; Options for the APC module version >= 3.1.3
; See http://www.php.net/manual/en/apc.configuration.php

; This can be set to 0 to disable APC.
apc.enabled=1

; The number of shared memory segments to allocate for the compiler cache.
apc.shm_segments=1

; The size of each shared memory segment, with M/G suffixe
apc.shm_size=64M

; A "hint" about the number of distinct source files that will be included or
; requested on your web server. Set to zero or omit if you're not sure;
apc.num_files_hint=1024

; Just like num_files_hint, a "hint" about the number of distinct user cache
; variables to store.  Set to zero or omit if you're not sure;
apc.user_entries_hint=4096

; The number of seconds a cache entry is allowed to idle in a slot in case this
; cache entry slot is needed by another entry.
apc.ttl=7200

; use the SAPI request start time for TTL
apc.use_request_time=1

; The number of seconds a user cache entry is allowed to idle in a slot in case
; this cache entry slot is needed by another entry.
apc.user_ttl=7200

; The number of seconds that a cache entry may remain on the garbage-collection list.
apc.gc_ttl=3600

; On by default, but can be set to off and used in conjunction with positive
; apc.filters so that files are only cached if matched by a positive filter.
apc.cache_by_default=1

; A comma-separated list of POSIX extended regular expressions.
apc.filters

; The mktemp-style file_mask to pass to the mmap module
apc.mmap_file_mask=/tmp/apc.XXXXXX

; This file_update_protection setting puts a delay on caching brand new files.
apc.file_update_protection=2

; Setting this enables APC for the CLI version of PHP (Mostly for testing and debugging).
apc.enable_cli=0

; Prevents large files from being cached
apc.max_file_size=1M

; Whether to stat the main script file and the fullpath includes.
apc.stat=1

; Vertification with ctime will avoid problems caused by programs such as svn or rsync by making
; sure inodes havn't changed since the last stat. APC will normally only check mtime.
apc.stat_ctime=0

; Whether to canonicalize paths in stat=0 mode or fall back to stat behaviour
apc.canonicalize=0

; With write_lock enabled, only one process at a time will try to compile an
; uncached script while the other processes will run uncached
apc.write_lock=1

; Logs any scripts that were automatically excluded from being cached due to early/late binding issues.
apc.report_autofilter=0

;This setting is deprecated, and replaced with apc.write_lock, so let's set it to zero.
apc.slam_defense=0

Restart Apache

Last, but not least, restart Apache:

[root@vps ~]# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

If you download a copy of apc.php and upload it to your web root, you’ll be able to test that APC is working properly.

Featured image by Jacob Jolibois.


Comments (2)

Previously posted in WordPress and transferred to Ghost.

mvo
March 25, 2014 at 6:15 am

pecl install apc-stable might be a little easier …

Ryan Sechrest
March 25, 2014 at 9:26 am

Where were you eight months ago?