Windows、XAMPP、PHP 7 和 opcache
我已经安装了最新的带有 PHP 7 的 XAMPP 服务器 (更新:还检查了 PHP 7.1)(在我的 Windows 10 系统上).想使用 opcache,所以我在 php.ini
中启用了它.
I've installed latest XAMPP server with PHP 7 (update: checked also PHP 7.1) (on my Windows 10 system). Wanted to use opcache, so I enabled it in php.ini
.
[opcache]
zend_extension=php_opcache.dll
opcache.enable=1
opcache.enable_cli=0
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
现在有了这个变化,几乎每次页面刷新,我都会从 Apache 收到这个错误:
With that change now, and with almost every page refresh, I'm getting this error from Apache:
AH00428: Parent: child process 3748 exited with status 3221226356 -- Restarting.
所以,页面正在加载,并且正在加载……等待 Apache 重新启动.当我关闭 opcache 时(通过设置 opcache.enable=0
),Apache 没有重新启动并且一切正常(当然忽略了较慢的 Web 应用程序主题).
So, page is loading, and loading... waiting to Apache start again. When I'm turning opcache off (by setting opcache.enable=0
), Apache is not restarting and everything works fine (omitting the slower web application topic, of course).
在 XAMPP 上加载具有 PHP 5.6 并启用 opcache
的应用程序时一切正常.
Everything works fine while loading app on XAMPP having PHP 5.6 with enabled opcache
.
编辑(添加 GIF 图片):
如您所见,有时页面会刷新.但有时它刷新的时间要长得多,而 Apache 会在那一刻重新启动.
EDIT (added GIF image):
As you can see, sometimes page refreshes like it should. But sometimes it's refreshing much longer, and Apache is restarting in that moment.
老实说,我放弃了这个应用程序并在 Windows 上使用 PHP(在 PHP <= 5.6 的情况下使用了大约 10 年).让 PHP 7.x 在该操作系统上工作(使用 Opcache)非常困难/不可能(目前).决定使用 Ubuntu 和使用 Docker 创建的服务器.一切都更容易配置(尤其是使用 Docker)并且运行速度更快.我建议每个人都这样做;).
To be honest, I gave up with this application and working with PHP on Windows (was working on it for around 10 years with PHP <= 5.6). It's very hard/impossible (for now) to make PHP 7.x work on that OS (with Opcache). Decided to go with Ubuntu and server created with Docker. Everything is easier to configure (especially with Docker) and works faster. I advise everyone to do the same ;).
推荐答案
你的php_opcache.dll
path似乎不对,你需要像下面这样写,它对我有用.
Your php_opcache.dll
path seems wrong, you need write it like below, it works for me.
[opcache]
zend_extension=C:xamppphpextphp_opcache.dll
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=256
opcache.max_accelerated_files=2000
更多详情
如果你的 XAMPP 默认带有 PHP 5.5+,opcache 已经包含在包中,你只需要启用它.启用扩展:
More details
If your XAMPP comes with PHP 5.5+ by default, opcache already included in the bundle, you will just need to enable it. To enable the extension:
打开 php.ini(默认情况下应该位于此处:C:xamppphpphp.ini).
Open php.ini (by default it should be located here: C:xamppphpphp.ini).
在文件末尾添加这一行:zend_extension=C:xamppphpextphp_opcache.dll
Add this line at the end of the file:
zend_extension=C:xamppphpextphp_opcache.dll
相关文章