It was shiny morning and at the time of taking tea at home. I opened my laptop and login into my server. Recently, I changed the apache MPM to worker mode. Running php-fpm and mod_fcgi to run the WordPress based blog.

After a few days of Worker apache implementation, I checked the php-fpm log directory and found some error that is

[root@mysites php-fpm]# tail www-error.log
[26-Jun-2014 13:39:34] PHP Warning: Unknown: Unable to allocate memory for pool. in Unknown on line 0
[26-Jun-2014 13:48:00] PHP Warning: Unknown: Unable to allocate memory for pool. in Unknown on line 0

To solve this issue, we optimize the php apc.

In CentOS/Red Hat and Scientific Linux, the absoute path of apc.php is /etc/php.d/apc.php

We optimize mainly these 4 values –

apc.shm_size
apc.num_files_hint
apc.user_entries_hint
apc.ttl

Optimizing the PHP apc takes time, I need some monitoring and playing around with these above 4 values.


Note: Detailed description on below given egrep command

[root@mysites php.d]# egrep -v '^;|^

Restart the apache and php-fpm

service httpd restart

service php-fpm restart

Visual Dashboard of PHP APC status

The PHP apc comes with awesome dashboard.

Copy apc.php file into DocumentRoot of your website. Replace /var/www/html/website-name with your website DocumentRoot

cp /usr/share/php-pecl-apc/apc.php /var/www/html/website-name

Change the password of apc dashboard.
Here default username s apc.

Find the below given line in apc.php file which you have copied into website DocumentRoot. Change the password.

defaults('ADMIN_USERNAME','apc');                       // Admin Username
defaults('ADMIN_PASSWORD','password');          // Admin Password - CHANGE THIS TO ENABLE!!!

Restart Apache and php-fpm once again

service httpd restart
service php-fpm restart

The below given is the reference from my live server. Still I am monitoring and optimizing the PHP APC. Right now error is gone and I marked it as solved.

php apc

PHP APC Documentation

apc.ini extension = apc.so apc.enabled=1 apc.shm_segments=1 apc.shm_size=128M apc.num_files_hint=20000 apc.user_entries_hint=20000 apc.ttl=7200 apc.use_request_time=1 apc.user_ttl=7200 apc.gc_ttl=3600 apc.cache_by_default=1 apc.filters apc.mmap_file_mask=/tmp/apc.XXXXXX apc.file_update_protection=2 apc.enable_cli=0 apc.max_file_size=20M apc.stat=1 apc.stat_ctime=0 apc.canonicalize=0 apc.write_lock=1 apc.report_autofilter=0 apc.rfc1867=0 apc.rfc1867_prefix =upload_ apc.rfc1867_name=APC_UPLOAD_PROGRESS apc.rfc1867_freq=0 apc.rfc1867_ttl=3600 apc.include_once_override=0 apc.lazy_classes=0 apc.lazy_functions=0 apc.coredump_unmap=0 apc.file_md5=0 apc.preload_path [root@mysites php.d]#

Restart the apache and php-fpm

 

Visual Dashboard of PHP APC status

The PHP apc comes with awesome dashboard.

Copy apc.php file into DocumentRoot of your website. Replace /var/www/html/website-name with your website DocumentRoot

 

Change the password of apc dashboard.
Here default username s apc.

Find the below given line in apc.php file which you have copied into website DocumentRoot. Change the password.

 

Restart Apache and php-fpm once again

 

The below given is the reference from my live server. Still I am monitoring and optimizing the PHP APC. Right now error is gone and I marked it as solved.

php apc

PHP APC Documentation

Read Some More Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.