PHP Warning: Unknown: Unable to allocate memory for pool. in Unknown on line 0
时间:2019-08-20 17:58:28 来源:igfitidea点击:
检查了phpfm日志目录,发现一些错误:
# tail www-error.log [26-Jun-2014 13:39:34] PHP Warning: Unknown: Unable to allocate memory for pool. in Unknown on line 0 [26-Jun-2014 13:48:00] PHP Warning: Unknown: Unable to allocate memory for pool. in Unknown on line 0
解决方案
为了解决这个问题,需要优化了phpac。
在CentOS/redhat中,apc.php的路径是/etc/php.d/apc.php
主要优化这4个值
- apc.shm_size
- apc.num_files_hint
- apc.user_entries_hint
- apc.ttl
优化时需要重复测试。
参考:
[root@mysites php.d]# egrep -v '^;|^$' apc.ini extension = apc.so apc.enabled=1 apc.shm_segments=1 apc.shm_size=128M apc.num_files_hint=20000 apc.user_entries_hint=20000 apc.ttl=7200 apc.use_request_time=1 apc.user_ttl=7200 apc.gc_ttl=3600 apc.cache_by_default=1 apc.filters apc.mmap_file_mask=/tmp/apc.XXXXXX apc.file_update_protection=2 apc.enable_cli=0 apc.max_file_size=20M apc.stat=1 apc.stat_ctime=0 apc.canonicalize=0 apc.write_lock=1 apc.report_autofilter=0 apc.rfc1867=0 apc.rfc1867_prefix =upload_ apc.rfc1867_name=APC_UPLOAD_PROGRESS apc.rfc1867_freq=0 apc.rfc1867_ttl=3600 apc.include_once_override=0 apc.lazy_classes=0 apc.lazy_functions=0 apc.coredump_unmap=0 apc.file_md5=0 apc.preload_path [root@mysites php.d]#
然后重启apache和php fpm
service httpd restart service php-fpm restart
查看APC状态
将apc.php复制到站点根目录:
cp /usr/share/php-pecl-apc/apc.php /var/www/html/website-name
修改apc控制面板的用户名和密码:(在apc.php文件中)
defaults('ADMIN_USERNAME','apc'); // Admin Username defaults('ADMIN_PASSWORD','password'); // Admin Password - CHANGE THIS TO ENABLE!!!
再次重新启动Apache和php fpm
service httpd restart service php-fpm restart
访问apc控制面板:
http://服务器ip/apc.php