<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/opcache.setup.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'opcache.installation.php',
    1 => '安装',
    2 => '安装',
  ),
  'up' => 
  array (
    0 => 'opcache.setup.php',
    1 => '安装/配置',
  ),
  'prev' => 
  array (
    0 => 'opcache.setup.php',
    1 => '安装/配置',
  ),
  'next' => 
  array (
    0 => 'opcache.configuration.php',
    1 => '运行时配置',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'reference/opcache/configure.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="opcache.installation" class="sect1">
 <h2 class="title">安装</h2>

 <p class="simpara">
  OPcache 只能编译为共享扩展。
  如果你使用 <strong class="option configure">--disable-all</strong> 参数
  禁用了默认扩展的构建，
  那么必须使用 <strong class="option configure">--enable-opcache</strong>
  选项来开启 OPcache。
 </p>

 <p class="simpara">
  编译之后，就可以使用
  <a href="ini.core.php#ini.zend-extension" class="link">zend_extension</a>
  指令来将 OPcache 扩展加载到 PHP 中。在非 Windows 平台使用
  <code class="literal">zend_extension=/full/path/to/opcache.so</code>，
  Windows 平台使用
  <code class="literal">zend_extension=C:\path\to\php_opcache.dll</code>。
 </p>

 <blockquote class="note"><p><strong class="note">注意</strong>: 
  <span class="simpara">
   如果想将 <a href="http://xdebug.org/" class="link external">&raquo;&nbsp;Xdebug</a> 与 OPcache 一起使用，必须在
   Xdebug 之前加载 OPcache。
  </span>
 </p></blockquote>

 <div class="sect2" id="opcache.installation.recommended">
  <h3 class="title">推荐的 php.ini 设置</h3>

  <p class="simpara">
   使用下列推荐设置来获得较好的
   性能：
  </p>

  <div class="informalexample">
   <div class="example-contents">
<div class="cdata"><pre>
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1 ; prior to PHP 7.2.0
</pre></div>
   </div>

  </div>

  <p class="simpara">
   你也可以禁用
   <a href="opcache.configuration.php#ini.opcache.save-comments" class="link">opcache.save_comments</a>
   并且启用
   <a href="opcache.configuration.php#ini.opcache.enable-file-override" class="link">opcache.enable_file_override</a>。
   需要提醒的是，在生产环境中使用上述配置之前，必须经过严格测试。
   因为上述配置存在一个已知问题，它会引发一些框架和应用的异常，
   尤其是在存在文档使用了备注注解的时候。
  </p>

  <p class="simpara">
   在 Windows 上，应该启用 <a href="opcache.configuration.php#ini.opcache.file-cache-fallback" class="link">opcache.file_cache_fallback</a>，以及应该将
   <a href="opcache.configuration.php#ini.opcache.file-cache" class="link">opcache.file_cache</a>
   设置为存在且可写的目录。
  </p>

  <p class="simpara">
   <a href="opcache.configuration.php" class="link">这里</a>是 OPcache
   可用的配置指令完整列表。
  </p>
 </div>
</div><?php manual_footer($setup); ?>