Networking

Unix and Linux network configuration. Multiple network interfaces. Bridged NICs. High-availability network configurations.

Applications

Reviews of latest Unix and Linux software. Helpful tips for application support admins. Automating application support.

Data

Disk partitioning, filesystems, directories, and files. Volume management, logical volumes, HA filesystems. Backups and disaster recovery.

Monitoring

Distributed server monitoring. Server performance and capacity planning. Monitoring applications, network status and user activity.

Commands & Shells

Cool Unix shell commands and options. Command-line tools and application. Things every Unix sysadmin needs to know.

Home » Apache

PHP Unable to allocate memory for pool

Submitted by on September 9, 2014 – 10:57 pm

The following error may be found in /var/log/httpd/${domain}/error_log when APC memory is set too low: “PHP Warning: require_once(): Unable to allocate memory for pool”. APC is Alternative PHP Cache. You can check the version of php-pecl-apc, httpd, and php installed on your system by running the following command:

rpm -qa | egrep "httpd-[0-9]|php-pecl-apc|php-[0-9]"

To address the issue, edit the php.ini and add/modify the following line:
apc.shm_size = 256M

The amount of memory you need can be determined by using the apc.php that comes as part of the php-pecl-apc package. On RHEL/CentOS the file is located in /usr/share/doc/php-pecl-apc-${version}/apc.php. Copy that file to your httpd root and chown it apache:apache, or whatever uid:gid your httpd is using. Additionally, edit this copy of apc.php to set username and password:
defaults('ADMIN_USERNAME','apc');      // Admin Username
defaults('ADMIN_PASSWORD','your_password');  // Admin Password

After making the change, restart httpd (/sbin/service httpd restart) and check the apc.php page again to see if the apc.shm_size value has changed. If not, edit /etc/php.d/apc.ini an update the apc.shm_size variable there as well. Restart httpd again and verify.

You may not want to keep the apc.php file on your server: just use it for tuning your PHP settings and then remove it. If you want to keep apc.php on the server for future use, I’d recommend password-protecting it. Here are the basic steps:

1. Generate username/password

/usr/bin/htpasswd -bc /var/www/htdocs/${domain}/.htpasswd ${username} ${password}

2. Add the following lines to /var/www/htdocs/${domain}/.htaccess
AuthUserFile /data/htdocs/${domain}/.htpasswd
AuthName "Login to view APC INFO"
AuthType Basic
<Files "apc.php">
  require valid-user
</Files>

3. Reload httpd configuration
/sbin/service httpd reload

 

Print Friendly, PDF & Email

Leave a Reply