PHP其实自带缓存扩展就可以让一般小主机良好运作,只要按照以下参考设置即可:
- 启用OPcache:
- 确保PHP的OPcache扩展已启用,这可以显著提高PHP脚本的执行速度。
- 在
php.ini
中启用OPcache: -
zend_extension=opcache.so opcache.enable=1 opcache.enable_cli=1 opcache.memory_consumption=128 opcache.interned_strings_buffer=8 opcache.max_accelerated_files=4000 opcache.revalidate_freq=60 opcache.fast_shutdown=1
- 启用APCu:
- APCu(Alternative PHP Cache User Cache)可以缓存用户数据,提高数据库查询速度。
- 在
php.ini
中启用APCu: -
extension=apcu.so apc.enabled=1 apc.shm_size=64M apc.ttl=7200 apc.user_ttl=7200 apc.gc_ttl=3600
没有回复内容