Linux/php/APC ON DEBIAN LENNY

From EasyWebDNS
Jump to: navigation, search

Installing PHP APC on Debian

Assuming your Debian Server already has PHP functioning under apache, you will need an extra few things, Run this apt-get to get them

apt-get install apache2-threaded-dev php5-dev php-pear make 

Don't forget to sudo On Ubuntu


Remember phpize, it is covered above ?

Now running the following command

pecl install apc

Will get APC installed, But we are not done yet, we need to enable it in PHP and tune it a bit

Now if you are running Debian Lenny for example, All you need to do to activate it is to upload the following file to /etc/php5/conf.d/apc.ini, then you can read the description of each and every one of the variables and adjust however you please.

extension=apc.so
apc.enabled=1
apc.shm_segments=1
apc.optimization=0
apc.shm_size=30
apc.ttl=7200
apc.user_ttl=7200
apc.num_files_hint=1024
apc.mmap_file_mask=/tmp/apc.XXXXXX
apc.enable_cli=0
apc.stat=on

Once the above is in a "Unix Text File" and uploaded to /etc/php5/conf.d/apc.ini You can tune the variables, the following section should help you do just that

1- apc.shm_size is in MB, to know how much shared memory your computer has execute

  cat /proc/sys/kernel/shmmax

B- Change the Maximum shared memory shmmax in the file

vi /etc/sysctl.conf
Add the line

kernel.shmmax = 67108864
to double the memory


Change apc.shm_size=30 to whatever you please now not exceeding the shmmax you specified for the OS, reboot don't just restart apache.

On Debian Lenny, a default 33554432 is in bytes


apc.enabled  boolean

This is only usefull if PHP is compiled with APC and you can not dissable it without going through much trouble, In most cases all you have to do is comment out the APC section in your php settings file and APC will dissapear.

apc.shm_segments integer

If APC consumes all the memory you have allocated to it, and APC is running out of shared memory, this setting (Depending on how your system is setup) can add 1 more unit of the apc.shm_size to the current shared memory used by APC and go on

apc.shm_size integer

In Megabytes, How much is every segment's size.

apc.optimization integer

Not recommended, Advice from us is to keep it set to zero (Disabled) as you never know what errors could arise and the benefits if any are not worth the trouble.

apc.num_files_hint integer

It is recomended that you set this to zero or omit it, Unless you have a good approximation on how many files will be on the server that will be cached.

apc.ttl integer

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. Leaving this at zero means that your cache could potentially fill up with stale entries while newer entries won't be cached. It is advised to keep this considerably low (15 minutes maybe), but it will depend on what application you are using and the setup you are running, For you see, if all your server does is run a few scripts that can all be cached and they seldome change, setting this to a higher value can't hurt


apc.gc_ttl integer

APC has a garbage collectior, and this is the number of seconds that a cache entry may remain on the garbage-collection list. The purpose this value serves has to do with things that happen very rarely (Like apache or PHP crashing), and you should not worry about this so much, leave it out or set it to Zero, and if your web server crashes often, there are better places to deal with such problems, I suggest a solution to the crashing rather than a working around it.

apc.cache_by_default boolean

This means APC should cache every PHP file that does not match a negative filter, it is on by default and files can be excluded with apc.filters, If you set this to off, the files you would like to have cached need to be added as a positive filter to apc.filters, A Sample is included below

apc.filters string

A SIMPLE example of an apc.filters line would be apc.filters = "mypath_criteria" this line means, if somewhere in the path to a file you see the

Domain Search:
.COM$ 7.49
.NET$ 6.49
.ORG$ 7.49
.INFO$ 1.99
Compare Pricing
Cheap Domains
Personal tools