Installing APC ( Alternative PHP Cache ) and configuration

Posted at September 22, 2016 at 5:53 pm by Jithin

APC stands for Alternative PHP cache. It is a PHP caching plugin. APC is a free open source opcode and it is a PECL module that can be loaded into PHP. PECL is a PHP Extension Community Library containing PHP extensions. PECL should be already in the cPanel servers along with the cPanel installation. APC is used to run PHP script executions more efficiently by cutting down on dynamic PHP executions and it provides a user cache for storing application data. APC is used to speedup PHP applications by caching both PHP code and user variables. It reduces server load and thereby improves the applications.

In PHP every time it requests for a page because it is a dynamic scripting language. For generating HTML code in the visitor’s web browser the server first parses the code in the PHP script. PHP is used for web pages that have content that is constantly updated. When you visit each time it will display a fresh copy of the page.

You need to re-run PHP scripts for data that might not have changed in the first place. APC allows to avoid repetition of PHP script executions, skipping the parsing and compiling steps. It stores the opcode that is executed each time the script is called again. APC is specific to PHP and it is used when local caching of objects in PHP scripts that are relatively small and frequently accessed. It is one of the most widely used PHP opcode caching solutions in use today. You can use APC on a VPS or dedicated server that is running PHP as either DSO or FastCGI.

 

Installing APC

1) Login to server via SSH.

2) Change the directory

   #cd /usr/local/src

3) Download the source code for APC and install it using wget.

   #wget http://pecl.php.net/get/APC-3.1.13.tgz

4) Extract the files.

  #tar -xf APC-3.1.13.tgz

5) Change tt the extracted folder.

  #cd APC-3.1.13

6) Run the below command to configure APC in PHP.

  # phpize

7) Run the following commands

 #./configure–enable-apc–enable-apc-mmap–with-apxs–with-php-config=/usr/bin/php-config

# make

# make test

# make install

8) Add APC settings to the php.ini file

 # vi /usr/local/lib/php.ini

extension=apc.so

apc.enabled=1

apc.shm_size=128

apc.cache_by_default=”1″

apc.shm_segments=”1″

apc.ttl=”7200″

apc.user_ttl=”7200″

apc.gc_ttl=”1800″

apc.optimization = 0

apc.num_files_hint=”1024″

apc.use_request_time = 1

apc.mmap_file_mask=”/tmp/apc.XXXXXX”

apc.enable_cli=”0″

apc.slam_defense=”0″

apc.file_update_protection=”2″

apc.max_file_size=”1M”

apc.stat=”1″

apc.write_lock=”1″

apc.report_autofilter=”0″

apc.include_once_override=”0″

apc.rfc1867=”0″

apc.rfc1867_prefix=”upload_”

apc.rfc1867_name=”APC_UPLOAD_PROGRESS”

apc.rfc1867_freq=”0″

apc.localcache=”0″

apc.localcache.size=”512″

apc.coredump_unmap=”0″

 

9) Save the settings in php.ini file and restart Apache.

  # /etc/init.d/httpd restart

 

If you need any further assistance please contact our support department.

 

 

5.00 avg. rating (89% score) - 1 vote

You can skip to the end and leave a response. Pinging is currently not allowed.

Leave a Reply