How to install APC on Linux

Written by AlanV on October 13, 2008 – 8:34 pm -

APC is a free, open, and robust framework for caching and optimizing PHP intermediate code.

Please make sure that you have root access to server. Access your server with root user and password

You can install APC either by downloading it from the source or by installing as pecl function.

Installation from the source

cd /usr/local/src

wget http://pecl.php.net/package/APC/3.0.19

This is latest version of APC

Alterative method

You can install it on command line by the command

pecl install apc

tar file will be downloaded under /tmp on server

Please move it to /usr/local/src by command

mv /tmp/APC-3.0.19.tgz /usr/local/src/

find phpize and php-config path on your server by the whereis command

whereis phpize

Output looks like:

phpize: /usr/bin/phpize /usr/local/bin/phpize

whereis php-config

Output looks like:

php-config: /usr/bin/php-config /usr/local/bin/php-config

Extract downloaded by the command gunzip

gunzip -c APC-3.0.19.tgz | tar xf -


Change to directory:

cd APC-3.0.19

Configure and compile it with apache by referencing path of phpize and php-config

/usr/bin/phpize
./configure –enable-apc –enable-apc-mmap –with-apxs=/usr/local/apache/bin/apxs –with-php-config=/usr/bin/php-config

make

make install

Take note of where it copies apc.so file i.e.

/usr/lib/php/extensions/no-debug-non-zts-20020429/apc.so

7. Now locate php.ini file:

locate php.ini
The default path for php.ini looks like

/usr/local/lib/php.ini

Edit php.ini using pico, vi or nano text editors in linux and scroll to section like

Code:

;Windows Extensions
;Note that MySQL and ODBC support is now built in, so no dll is needed for it.
;
;extension=php_bz2.dll

Add above that the following so it looks like

Code:

extension="apc.so"
apc.shm_size = 32 
 
;Windows Extensions
;Note that MySQL and ODBC support is now built in, so no dll is needed for it.
;
;extension=php_bz2.dll

Save php.ini file and restart Apache for APC to load

/etc/init.d/httpd stop
/etc/init.d/httpd start

Check phpinfo.php for APC section just to confirm whether APC is enabled and compiled on server.

Create phpinfo.php under /usr/local/apache/htdocs/ as per following to check APC

touch phpinfo.php

/usr/local/apache/htdocs/ is default document root on all cPanel servers.

vi phpinfo.php and add following codes into it

<?

phpinfo();

?>

Press :wq for the save and exit

Now you can check APC at URL http://server_IP/info.php

apc.php admin file in /usr/local/src/APC-3.0.19 can be copied to password protected web site directory and viewed. Edit apc.php top line to change password to something different from default.


Tags: , , , , ,
Posted in Dedicated Server Hosting | No Comments »

Leave a Comment

RSS

  • Subscribe Me

  • Tag Cloud

  • Archives