Windows, XAMPP, PHP 7 and opcache

拜拜、爱过 提交于 2019-11-30 01:38:38

问题


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

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.

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).

Everything works fine while loading app on XAMPP having PHP 5.6 with enabled opcache.

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.

EDIT:
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 ;).


回答1:


Your php_opcache.dll path seems wrong, you need write it like below, it works for me.

[opcache]
zend_extension=C:\xampp\php\ext\php_opcache.dll
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=256
opcache.max_accelerated_files=2000

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:

  1. Open php.ini (by default it should be located here: C:\xampp\php\php.ini).

  2. Add this line at the end of the file: zend_extension=C:\xampp\php\ext\php_opcache.dll

  3. Restart Apache server.



回答2:


open a php.ini file

  1. Change the ;opcache.enable=1 to opcache.enable=1
  2. Add opcache dll path at the end of the file zend_extension = "C:\xampp\php\ext\php_opcache.dll"
  3. Restart apache

for more reference check this video https://www.youtube.com/watch?v=GvWrNoRDjUY




回答3:


To be honest - do not use xammp. Right now we have a bit better tech stack, to run PHP on Linux servers. Docker https://docs.docker.com/docker-for-windows/

Vagrant: https://www.vagrantup.com/

Both of them are based on linux systems, where most of xammp problems will not have place.




回答4:


In case of Xampp, just put the below lines next to [opcache]

zend_extension="C:\xampp\php\ext\php_opcache.dll"
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=256
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1



回答5:


Creeating directory with appropriate permissions and setting it php.ini worked!

opcache.file_cache=d:\xampp\htdocs\opcache



回答6:


ThreadStackSize 8388608 

Helped me in the similar case. This is a httpd option.



来源:https://stackoverflow.com/questions/41028599/windows-xampp-php-7-and-opcache

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!