magento -- 给服务器安装APC提升服务器的性能容量
欢迎转载,请注明来源:blog.csdn.net/xinhaozhengmagento的性能,我在这上面不知道花了多少时间.已经试过了eaccelerator,非常不错.也来试试APC.因为据说它比较稳定.不管什么说要试试看,只要有利于提高速度的. 说明:APC,全称是Alternative PHP Cache (APC),是一个开源的PHP缓存扩展模块.它的目的是为PHP编译字节码的
欢迎转载,请注明来源:blog.csdn.net/xinhaozheng
magento的性能,我在这上面不知道花了多少时间.已经试过了eaccelerator,非常不错.也来试试APC.因为据说它比较稳定.不管什么说要试试看,只要有利于提高速度的.
说明:APC,全称是Alternative PHP Cache (APC),是一个开源的PHP缓存扩展模块.它的目的是为PHP编译字节码的缓存和代码优化提供一个免费开源而又稳定的框架.
安装apc
前提:
没有要求或依赖于其它的任意模块
安装步骤
安装APC 有很多方法,不过推荐使用pecl.它和pear一样,非常好用,甚至好些选项,命令都是一样的.
#cd /usr/local/php/bin
# ./pecl install apc
如果有碰到问题请参考:ear.php.net is using a unsupported protocal
# cd /usr/local/php/lib/php/.channels
#rm pear.php.net.reg
# rm pecl.php.net.reg
#cd /usr/local/php/bin
# ./pecl updae-channels
Updating channel "doc.php.net"
Channel "doc.php.net" is up to date
Updating channel "pear.php.net"
Update of Channel "pear.php.net" succeeded
Updating channel "pecl.php.net"
Channel "pecl.php.net" is up to date
# ./pecl install apc
Sorry, I was not able to successfully run APXS. Possible reasons:
1. Perl is not installed;
2. Apache was not compiled with DSO support (--enable-module=so);
3. 'apxs' is not in your path. Try to use --with-apxs=/path/to/apxs
The output of apxs follows
/tmp/pear/temp/APC/configure: line 3439: apxs: command not found
configure: error: Aborting
ERROR: `/tmp/pear/temp/APC/configure --with-apxs' failed
我是安装了perl,而且在编译安装apache时也必然启用了 --enable-so,所以判断是第三种情况,编译程序找不到apxs,在当前的查找路径找不到,解决方法,简单的你可以在bin目录给apxs创建一个软件链接,如
ln -s /usr/local/apache2/bin/apxs /bin/apxs
不过再次运行命令安装时我发现可以直接在它停下来询问时指定apxs的路径:
[root@LSN-D3092 bin]# ./pecl install apc
downloading APC-3.0.19.tar ...
Starting to download APC-3.0.19.tar (Unknown size)
.....................done: 564,736 bytes
47 source files, building
WARNING: php_bin /usr/local/php/bin/php appears to have a suffix /bin/php, but config variable php_suffix does not match
running: phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
Use apxs to set compile flags (if using APC with Apache)? [yes] :n(注意我用n)
...........
The output of /var/tmp/pear-build-root/APC-3.0.19/n follows
/tmp/pear/temp/APC/configure: line 3439: /var/tmp/pear-build-root/APC-3.0.19/n: No such file or directory
configure: error: Aborting
ERROR: `/tmp/pear/temp/APC/configure --with-apxs=n' failed (这行错误提示说明我们可以直接指定)
所以再来一次:
[root@LSN-D3092 bin]# ./pecl install apc
downloading APC-3.0.19.tar ...
Starting to download APC-3.0.19.tar (Unknown size)
.....................done: 564,736 bytes
47 source files, building
WARNING: php_bin /usr/local/php/bin/php appears to have a suffix /bin/php, but config variable php_suffix does not match
running: phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
Use apxs to set compile flags (if using APC with Apache)? [yes] :/usr/local/apache2/bin/apxs
这样apc就被编译成一个so扩展,不过你需要修改php配置文件来加载,同时要设置相应的参数.首先呢,把这行加过去,
extension=apc.so
然后你可以在 php.ini中添加一个APC section
[APC] //这个名称可以随意的
apc.enabled = "1"
apc.shm_size=256
apc.num_files_hint=10000
apc.user_entries_hint=10000
apc.max_file_size=5M
再进一步, 在magento的app/etc/local.xml中添加如下配置(欢迎转载,请注明来源:blog.csdn.net/xinhaozheng )
更多推荐
所有评论(0)