我正试图安装一个gentoo与PHP 5.2的APC在这里完整的命令我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
make install命令显示
Installing shared extensions: /usr/local/php5/lib/php/extensions/no-debug-non-zts-20060613/ Installing header files: /usr/local/php5/include/php/
当我做完后, make test输出是:
===================================================================== 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] =====================================================================
我已经在/usr/local/lib64/php5/php.ini添加了extension=apc.so extension_dir是extension_dir = "./"
为了使apc加载,我必须把apc.so文件放在我的www目录中。 现在phpinfo(); 说它被加载。
问题是apc_store不能有效地存储请求之间的数据 。
$bar = 'BAR'; apc_store('foo', $bar); var_dump(apc_fetch('foo'));
在一个请求这个工作。
现在,如果我尝试做一个var_dump(apc_fetch('foo')); 在另一个请求打印:
bool(false)
就像APC没有在后台运行一样,但是它只对每个请求启动
这不是值得的问题? 🙁
根据您提供的信息,您似乎已经从头开始编译了大部分必需的软件包,而不是使用称为Portage的Gentoo软件包pipe理系统。 除非你确切地知道你在做什么,否则采取从源代码安装的路线通常是一个坏主意。 虽然Portage的默认行为也是从源代码安装软件包,但它有一个先进的依赖pipe理工具集,可以自动处理大多数复杂的依赖关系,使得更新和删除软件包变得非常轻松。
您指定的以下文件和目录位置在典型的Gentooconfiguration中都是非标准的,并且肯定会导致相互依赖的包失败或意外崩溃:
/usr/local/lib64/php5/php.ini /etc/init.d/httpd /usr/local/php5/bin/phpize
如果这不是一个生产箱,而且你可以节省停机时间,那么我build议完全删除Apache和PHP,然后使用Portage重新安装它们,如下所示:
安装Apache:
emerge -av www-servers/apache
接下来,您将需要安装PHP,但一定要设置apache2 USE标志。 将您的USE标志添加到/etc/portage/packages.use可确保在将来的更新中保留它们。 在/etc/portage/packages.use为PHP设置的一组典型USE标志将如下所示:
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
你应该能够删除我在这个例子中提供的大部分USE标志,除了apache2标志。 您的特定需求将确定您需要设置的USE标志,但对于可与Apache协同工作的PHP的基本安装,您只需要设置apache2标志。
现在您已经设置了USE标志,您可以继续安装PHP:
emerge -av dev-lang/php
一旦PHP安装成功,您可以通过在文本编辑器中打开/etc/conf.d/apache2并确认以APACHE2_OPTS开头的行包含指令-D PHP5来确认它已正确configuration为与Apache一起工作。
您现在可以通过调用正确的init脚本来启动Apache:
/etc/init.d/apache2 start
此时启动Apache应该没有问题。 下一步需要对PHP进行一些更改,所以你应该再次停止Apache。
Gentoo将PHPconfiguration文件拆分为两个独立的目录,一个用于configurationPHP CLI,另一个用于configurationApache使用的PHP。 这些目录如下所示:
/etc/php/cli-php5/php.ini /etc/php/apache2-php5/php.ini
您的确切path可能略有不同,具体取决于您安装的PHP的确切版本。
最后一步是使用Portage再次安装APC:
emerge -av dev-php5/pecl-apc
一旦APC成功安装,您可能需要编辑/etc/php/apache2-php5/php.ini文件来检查APC是否正确configuration,并确保Apache启动时加载扩展名。 检查以下内容是否存在于php.ini文件中:
apc.enabled=1 apc.shm_size=32
PHP在线文档提供了完整的APCconfiguration指令列表。
您现在已经完成了正确configurationGentoo环境的Apache,PHP和APC扩展所需的所有步骤。 重新启动Apache完成。
/etc/init.d/apache2 restart
过去我也有类似的问题
尝试将此行添加到您的PHPconfiguration
apc.mmap_file_mask=/tmp/apc.XXXXXX apc.shm_size=48
无论如何,你为什么不使用gentoo的pecl-apc包?