|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57555 Apc doesn't work and for CGI cause a 500 Internal server error
Submitted: 2007-03-02 17:52 UTC Modified: 2009-03-22 19:52 UTC
From: pascal at carat-hosting dot com Assigned:
Status: Not a bug Package: APC (PECL)
PHP Version: 4.4.4 OS: Centos 4.4 x86_64
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: pascal at carat-hosting dot com
New email:
PHP Version: OS:


 [2007-03-02 17:52 UTC] pascal at carat-hosting dot com
- PHP Version : 4.4.4 (and 5.2.0 as CGI with suPHP)
- Zend Optimiser. 
- APC : 3.0.13
Created with :
  ./configure --enable-apc --enable-apc-mmap --with-apxs --with-php-config=/usr/bin/php-config
  make install

No error during installation. has been created in /usr/lib64/php4/

APC config is the default one

A phpinfo() show APC as running. 
apc.php shows APC too.

1 - Run php files with php as apache module
It looks like there is no cache. 
Indeed apc.php shows no file as cached !

2 - If we run a php script as CGI
We have some vhosts that run PHP4 as CGI, in this case we have a 500 Internal server Error
In logs the error is

Premature end of script headers: phpinfo.php
[apc-error] apc_mmap: mmap failed: Cannot allocate memory


Why it doesn't work (without error) with php as module ?
is it possible to run APC with CGI php ?
Does it work with PHP5.2 ?

Thanks for your help



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-02 20:07 UTC]
APC works fine with PHP 5.2.

Running it for CGI doesn't make much sense since the cache is going to get destroyed at the end of each request.

For the Apache module case, remove the Zend Optimizer.
 [2007-03-02 21:07 UTC] pascal at carat-hosting dot com

APC is it working or not with zend optimiser ? 
Maybe I have to install APC before zend ?
What happens if I need the zend loader ?

About PHP as CGI, what about FastCGI, it makes sense to have a cache system with FastCgi ? 

On the same box we use different PHP
PHP4 as module (90% of use)
PHP4 as CGI and/or PHP5 as CGI

If I understand well the only way to not setup APC for php4 as cgi and php5 as cgi should be to have different php.ini ?

For example
php-cgi.ini --> cgi
php.ini --> module

Right ?

Thanks for your help

 [2009-03-22 19:52 UTC]
The allocation error is likely because you're cache size exceeds the size of your compiled source files, so increasing shm_size should help.  But as Rasmus says this doesn't make much sense on CGI as it only lasts for that process' life, and you'll cost more time and memory than you'll save. APC is not compatible with other opcode caches and is likely to have issues with Zend optimizers etc.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 22 07:01:29 2024 UTC