2

I am trying to install APC on a gentoo with php 5.2 Here teh full command i Lanched:

mkdir /home/APC-php
cd /home/APC-php
wget http://pecl.php.net/get/APC
tar -xzvf APC
cd APC-3.1.9
/usr/local/php5/bin/phpize
./configure --enable-apc --enable-apc-mmap --with-php-config=/usr/local/php5/bin/php-config
make
make test (i think almost everything failed here)
make install
/etc/init.d/httpd restart

The make install command showed

Installing shared extensions:     /usr/local/php5/lib/php/extensions/no-debug-non-zts-20060613/
Installing header files:          /usr/local/php5/include/php/

When I did after make, make test the output was:

=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
APC: apc_store/fetch with strings [tests/apc_001.phpt]
APC: apc_store/fetch with objects [tests/apc_002.phpt]
APC: apc_store/fetch with objects (php pre-5.3) [tests/apc_003.phpt]
APC: apc_store/fetch with bools [tests/apc_004.phpt]
APC: apc_store/fetch with arrays of objects [tests/apc_005.phpt]
APC: apc_store/fetch reference test [tests/apc_006.phpt]
APC: apc_inc/apc_dec test [tests/apc_007.phpt]
APC: apc_cas test [tests/apc_008.phpt]
APC: apc_delete_file test [tests/apc_009.phpt]
APC: apc_store/fetch/add with array of key/value pairs. [tests/apc_010.phpt]
APC: bindump user cache [tests/apc_bin_001.phpt]
APC: bindump file cache part 1 [tests/apc_bin_002.phpt]
APC: APCIterator general [tests/iterator_001.phpt]
APC: APCIterator regex [tests/iterator_002.phpt]
APC: APCIterator chunk size [tests/iterator_003.phpt]
APC: APCIterator regex & chunk size & list [tests/iterator_004.phpt]
APC: APCIterator delete [tests/iterator_005.phpt]
APC: APCIterator formats [tests/iterator_006.phpt]
APC: APCIterator Overwriting the ctor [tests/iterator_007.phpt]
=====================================================================

I already added extension=apc.so in /usr/local/lib64/php5/php.ini The extension_dir is extension_dir = "./"

To make apc loaded I had to put the apc.so file in my www directory. Now phpinfo(); says it's loaded.

The problem is that apc_store doens't effectively store the data between requests.

$bar = 'BAR';
apc_store('foo', $bar);
var_dump(apc_fetch('foo'));

Within one request this work.

Now If i try to do a var_dump(apc_fetch('foo')); on another request it prints:

bool(false)

It is like APC isn't running in background but it starts only for each requests

Isn't this bounty worth the question? :(

3
  • What does locate phpize show (you may have to emerge slocate and run updatedb first)? Is PHP 5.2 installed through portage or manually compiled? I see you're specifying /usr/local/bin/php-config as your php-config, did you try /usr/local/bin/phpize? May 27, 2011 at 0:31
  • Thanks! I found that all bins where in /usr/local/php5/bin I did all that commands and restarted apache but still the apc_* func where not available :(
    – dynamic
    May 27, 2011 at 10:00
  • Ugh. Gentoo. Good luck with that. Jun 3, 2011 at 16:45

2 Answers 2

0
+150

From the information you've provided, it looks like you've compiled most of your required packages from scratch rather than using the Gentoo package management system known as Portage. Taking the install-from-source route is generally a bad idea unless you know exactly what you're doing. While it is true that the default behaviour of Portage is also to install packages from source, it has an advanced dependency management toolset which handles most complex dependencies automatically, and makes updating and removing packages quite painless.

The following files and directory locations which you specified are all non-standard in a typical Gentoo configuration, and will most certainly cause interdependent packages to fail or crash unexpectedly:

/usr/local/lib64/php5/php.ini
/etc/init.d/httpd
/usr/local/php5/bin/phpize

If this is not a production box, and you can spare the downtime, I suggest completely removing Apache and PHP, and then reinstall them using Portage as follows:

Install Apache:

emerge -av www-servers/apache

Next, you'll need to install PHP, but be sure to set the apache2 USE flag. Adding your USE flags to /etc/portage/packages.use ensures that they will be retained across future updates. A typical set of USE flags set for PHP in /etc/portage/packages.use will look like this:

dev-lang/php apache2 berkdb bzip2 calendar cli crypt ctype curl curlwrappers fileinfo filter ftp gd gdbm hash iconv imap inifile ipv6 json ldap mssql mysql mysqli nls pdo phar posix readline session simplexml snmp soap sockets spell sqlite ssl threads tokenizer truetype unicode xml xmlrpc xsl zip zlib

You should be able to remove most of the USE flags I provided in this example, except for the apache2 flag. Your particular requirements will determine the USE flags you need to set, but for a base installation of PHP which will work with Apache, you only require the apache2 flag to be set.

Now that you have the USE flags set, you can go ahead and install PHP:

emerge -av dev-lang/php

Once PHP has installed successfully, you can confirm that it has been correctly configured to work with Apache by opening /etc/conf.d/apache2 in a text editor and checking that the line starting with APACHE2_OPTS contains the directive -D PHP5.

You can now start Apache by invoking the correct init script:

/etc/init.d/apache2 start

There should be no problems starting Apache at this point. The next step requires some changes to PHP, so you should stop Apache again in the meantime.

Gentoo splits the PHP configuration files into two separate directories, one for configuring the PHP CLI, and the other for configuring PHP used with Apache. These directories are as follows:

/etc/php/cli-php5/php.ini
/etc/php/apache2-php5/php.ini

Your exact path may differ slightly depending on the exact version of PHP you have installed.

The last step is to install APC, again using Portage:

emerge -av dev-php5/pecl-apc

Once APC has been successfully installed, you may need to edit the /etc/php/apache2-php5/php.ini file to check that APC is correctly configured and to ensure that PHP loads the extension when Apache is started. Check that the following are present in the php.ini file:

apc.enabled=1
apc.shm_size=32

The full list of APC configuration directives are available here on the PHP online docs.

You have now completed all steps required for correctly configuring Apache, PHP and the APC extension for a Gentoo environment. Restart Apache to finish.

/etc/init.d/apache2 restart
1
  • without even reading +150
    – dynamic
    Jun 5, 2011 at 22:54
0

I had similar problems in the past.

Try to add this line to your php config

apc.mmap_file_mask=/tmp/apc.XXXXXX
apc.shm_size=48

Anyway, why aren't you using pecl-apc package from gentoo?

4
  • the problem is i ma under CGI interface. I dunno how to change that
    – dynamic
    Jun 3, 2011 at 15:42
  • 1
    Probably that's the problem, APC doesn't share memory between processes, and CGI create a new process per request. May be the answer is to use something else, like memcached.
    – erickzetta
    Jun 3, 2011 at 17:45
  • hm! good tip!.. but is that hard to run php normally under apache?
    – dynamic
    Jun 3, 2011 at 18:09
  • Usually, it's very easy. In gentoo, just install apache and php with apache2 useflag.
    – erickzetta
    Jun 3, 2011 at 20:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .