apt-get install php-apc
自动安装的是php-apc 3.1.7-1版本。
然后直接写测试脚本:
<?php $constants = array('APC_FILE' => 'apc.php', 'AUTHOR' => 'ccccccc'); apc_define_constants('numbers', $constants); apc_load_constants('numbers'); echo 'APC_FILE='.APC_FILE.' '; echo 'AUTHOR='.AUTHOR."\n"; ?>
运行通过。用php命令直接执行脚本打印phpinfo信息,里面有:
Loaded Configuration File => /etc/php5/cli/php.ini Scan this dir for additional .ini files => /etc/php5/cli/conf.d Additional .ini files parsed => /etc/php5/cli/conf.d/apc.ini, /etc/php5/cli/conf.d/curl.ini, /etc/php5/cli/conf.d/mysql.ini, /etc/php5/cli/conf.d/mysqli.ini, /etc/php5/cli/conf.d/pdo.ini, /etc/php5/cli/conf.d/pdo_mysql.ini
可见apc模块已加入。将apc测试程序拷入apache测试目录下,在网页中访问,出错。重启apache2服务器(/etc/init.d/apache2 restart),再次访问,成功。
原创文章,作者:苏葳,如需转载,请注明出处:https://www.swmemo.com/449.html