Install APC with XAMPP on Linux

Prerequisite

If you don’t already have the XAMPP development files installed you must install them first. The XAMPP development files can be downloaded from here.

Alternatively to install the XAMPP development files run the following commands:

wget -O xampp-dev-files.tar.gz http://www.apachefriends.org/download.php?xampp-linux-devel-1.8.1.tar.gz
sudo tar xvfz xampp-dev-files.tar.gz -C /opt

Important: Change 1.8.1 in the above wget command to the latest version listed on the XAMPP website linked above.

Installing APC

First download and extract the APC source files:

wget -O apc-latest.tar.gz http://pecl.php.net/get/APC
tar xvfz apc-latest.tar.gz
cd APC-*

Then run phpize in the APC source directory:

/opt/lampp/bin/phpize

Run configure (64-bit users see below for 64-bit instructions):

./configure --with-php-config=/opt/lampp/bin/php-config

Compile and install:

make
sudo make install

Finally add “extension=apc.so” to the php.ini file and restart XAMPP:

sudo sh -c "echo 'extension=apc.so' >> /opt/lampp/etc/php.ini"
sudo /opt/lampp/lampp restart

Linux/Ubuntu x64

XAMPP is compiled as 32-bit so if you are using 64-bit Linux you will need to compile APC as 32-bit.

First install the 32-bit development libraries:

sudo apt-get install libc6-dev-i386

Next change the configure command in the above instructions to:

 ./configure --build=i686-pc-linux-gnu "CFLAGS=-m32" "CXXFLAGS=-m32" "LDFLAGS=-m32" --with-php-config=/opt/lampp/bin/php-config

Then just proceed with the instructions above.

Errors

When restarting XAMPP it ouputs a wrong ELF class error
See above 64-bit section. Before running the “make” command again make sure to run “make clean” to get rid of any previous 64-bit build.
Fatal error: php.h: No such file or directory
You must have the XAMPP development files installed and also run /opt/lampp/bin/phpize in the APC source directory.

Comments