php中的主动APC

php中的主动APC,php,apache,apc,Php,Apache,Apc,我已经在我的服务器上安装了APC PHP。PHPinfo正在展示它。但我有一个问题,因为我有点困惑 到达服务器的新PHP请求将自动开始使用APC,还是PHP代码也需要修改以使用APC?你能提供一些线索吗 谢谢,PHP将自动使用它。要使用缓存加速器,您根本不需要更改代码。APC正在自动运行。模块运行您的代码并将其转换为字节码。当您再次调用脚本时,Web服务器不会再次运行脚本,而是执行字节码 如果你有很多流量,它可以节省很多性能 第二个功能是,如果需要,可以从APC将值保存在共享内存中。为此,您应该

我已经在我的服务器上安装了APC PHP。PHPinfo正在展示它。但我有一个问题,因为我有点困惑

到达服务器的新PHP请求将自动开始使用APC,还是PHP代码也需要修改以使用APC?你能提供一些线索吗


谢谢,PHP将自动使用它。要使用缓存加速器,您根本不需要更改代码。

APC正在自动运行。模块运行您的代码并将其转换为字节码。当您再次调用脚本时,Web服务器不会再次运行脚本,而是执行字节码

如果你有很多流量,它可以节省很多性能

第二个功能是,如果需要,可以从APC将值保存在共享内存中。为此,您应该阅读文档


如果存在apc,将使用它。除非
apc.enabled
的默认值为False,否则请在phpinfo中检查它

如果启用的设置正常,则第一次apc使用将是tho操作码。存储php脚本的“编译”版本。现在,通过打开H apc的多个设置(比如避免在每次文件访问时检查源代码修改),可以极大地改善这种行为

APC还有第二大功能,即将其用作应用程序的持久性/缓存存储。但这些东西需要在应用程序中有特定的应用程序说明,就像使用datatabase一样。检查

要真正激活APC优化,您应该查看所有APC设置<代码>apc.shm_大小和
apc.shm_段
是检查apc内存大小设置最有用的,并为所有病毒库共享。但是在这些基本设置之后,您应该检查virtualhost/应用程序(您将在其中使用php_值指令)或全局php.ini中的一些内容,这是生产配置的摘录:

请注意,您应该了解每个激活的设置,否则您将在开发过程中损失数小时,因为您的源代码更改不会被php读取

# Activate apc
apc.enabled =1
# Optimisation of include/require_once calls
apc.include_once_override =1
# transform paths in absolute ones (no effect if apc.stat is not 0),
# files from stream wrappers (extended includes)
# won't be cached if this is activated as they cannot be used with php's realpath()
apc.canonicalize  =1  
# In production set it to 0, then file changes won't be observed before 
# apache is restarted,
# significant boost, else file time is stated at each access (needed at 1 in dev)
apc.stat =0
# avoid problems with rsync or svn not modifying mtime but only ctime
# so if you're in production set this to 0, like for the previous one 
apc.stat_ctime =0  

# deprecated option: apc.optimization not available anymore
# apc.optimization =0  

# inform apc on number of files of the application
apc.num_files_hint =2000

# inform apc on the number of cache variables
apc.user_entries_hint =100

# cache lifetime managmenent ----------------
# time (s) we can stay on the cache even when the cache is full -- Cache full count --
# that means Garbage Collector is never inactivating theses datas before this time is over
# >0 -> old data could stay in the cache while new data want's to come, if no data is deprecated
# 7200 -> entries older than 2 hours will be thrown to make some place
# 0 -> emptying full cache when full
apc.ttl =0
apc.user_ttl =0
# this one is the same but you should note this this prevent Garbage collecting 
# after each source change.
apc.gc_ttl =0

# What to cache ? ----------------------------
# could be used to prevent some caching on specific files
# but it's better to cache often used files, isn't it? at least in production
#apc.filters  ="-config.php-.ini"
# default to 1M, files bigger than that won't be cached
apc.max_file_size  ="5M"

# various things -------------------------------
# only one process caching a same file (beter than apc.slam_defense)
php_fla apc.write_lock  =1  
# prevents caching half written files (by cp for example) by waiting x seconds
# for new files caching. set it to 0 if using only rsync or mv
apc.file_update_protection  =2
# newest versions of APC only
# adding a lazy loading capabilities, so you can parse a lot of files
# and only used things are cached
#apc.lazy_functions =1
#apc.lazy_classes  =1

我已经看到,通过安装简单页面请求和每秒传输量的模块,速度略有提高。但除非你做了一些测试,不管有没有,你都不能确定。查看Apache Bench实用程序,您也可以使用它手动缓存内容。。。