05 Nov
I’ve lost count how many times I’ve needed to recompile a new version of APC for PHP on my server, so this mainly serves as a reminder on how to do it for next time.
- Go to http://pecl.php.net/package/APC and find the latest download link at the time.
- Login via SSH and go into root login via
su - - Navigate to the source folder:
cd /usr/local/src
- wget the latest download from the PHP pecl link above. (i.e. wget http://pecl.php.net/get/APC-3.0.15.tgz)
- Unzip the archive like so:
gunzip -c APC-3.0.15.tgz | tar xf -
- Navigate to the APC folder:
cd APC-3.0.15 - phpize the APC folder to make the correct configuration file: /usr/bin/phpize
- Make the configuration file:
./configure --enable-apc --enable-apc-mmap --with-apxs --with-php-config=/usr/bin/php-config
- Start the compile:
make
- Finish and install:
make install
- Edit the php.ini file to enable the APC module based on the location provided from the previous command:
pico -w /usr/lib/php.ini
- Finally restart apache to see the changes:
service httpd restart
The important bits you need to put inside php.ini are the extension call like so:
extension = "apc.so"
You then also need to enable and configure APC to your liking. Here’s my setup:
apc.enabled = 1 apc.shm_size = 64 apc.ttl = 3600 apc.user_ttl = 3600 apc.optimization = 0 apc.filters = "-Gallery.*\.class, wp-cache-config, -mint.php" apc.include_once_override=1 apc.write_lock=1
Other things you need to take into account is your PHP extension_dir setting. This needs to be set right to be able to load the module correctly above.
You should also bear in mind that /usr/bin/phpize and /usr/bin/php-config could be different for your system setup.
[...] programs that might be affected by the change. So that was easy. Next comes the installation of the an article that explained how to install APC via SSH. This was the easy part and was done in a few seconds. [...]
[...] You do have the option to enable PHP suEXEC for additional security, although if you enable this you won’t be able to use an opcode cache like APC. [...]