任何文件更改后 Laravel 连接重置 [英] Laravel connection reset after any file changes
问题描述
我在本地环境(Windows 10)中安装了 laravel 4.2 进行测试,但在更新任何文件后不断收到连接重置错误.
I have laravel 4.2 installed in a local environment (windows 10) for testing, but keep getting a connection reset error after updating any files.
我的项目将加载并且服务器正确显示我的页面.但是,如果我更新文件(例如索引),然后尝试访问呈现新更新文件的页面,我总是会收到连接重置错误.哪怕只是一个句号那么简单的变化.
My project will load and the server properly displays my pages. However if I update a file (index for example) and then try access a page that renders the newly updated file, I always get a connection reset error. Even a change as simple as a period.
更有趣的是,当我使用 php artisan 为我的文件提供服务时,我从未遇到连接重置问题.如果我通过 artisan serve 访问页面,它会工作,然后突然 xampp 想要工作,但只有在我之前从 artisan 加载过页面之后.
Even more interesting is when I use php artisan to serve my files, I never get the connection reset problem. If I visit the page through artisan serve it works, and then all the sudden xampp wants to work, but only after I have loaded the page from artisan once before.
如果我再次对文件进行更改,则必须重复此过程.
If I make changes to the file again I have to repeat this process.
本地设置
我的项目使用以下 v-hosts 配置从 xampp (v 3.2.2) 本地托管.主机文件也已正确配置.
My project is being hosted locally from xampp (v 3.2.2) with the following v-hosts config. The hosts files have also been properly configured.
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/myproject/public"
ServerName myproject.local
ServerAlias myproject.local
ErrorLog "logs/myproject.log"
CustomLog "logs/custom.myproject.log" combined
<Directory "C:/xampp/htdocs/myproject/public">
AllowOverride All
Require all granted
</Directory>
简而言之:我更改了一个文件,尝试访问该页面时,我在 xampp 上重置了连接.我从工匠那里查看页面,然后在 xampp 上刷新页面,突然它就可以工作了.
In short: I change a file, I get connection reset on xampp when trying to access that page. I view the page from artisan and then refresh the page on xampp, all the sudden it works.
更新
我尝试了 Lucas 建议的替代方法,例如 laragon,但是同样的错误仍然存在.在尝试访问该页面时更新任何文件后,我收到连接重置错误.
I have tried alternates such as laragon suggested by Lucas, however the same error persists. After updating any file when trying to access that page I get a connection reset error.
通过查看 laragon 中的 apache 日志,我发现了更多信息.
I have found more information looking at the apache log in laragon.
[Tue Mar 01 08:52:22.785519 2016] [mpm_winnt:notice] [pid 6748:tid 544] AH00428: Parent: child process 8276 exited with status 3221225725 -- Restarting.
[Tue Mar 01 08:52:22.928687 2016] [ssl:warn] [pid 6748:tid 544] AH01909: www.example.com:8443:0 server certificate does NOT include an ID which matches the server name
[Tue Mar 01 08:52:22.938712 2016] [mpm_winnt:notice] [pid 6748:tid 544] AH00455: Apache/2.4.17 (Win32) OpenSSL/1.0.2d PHP/5.6.16 configured -- resuming normal operations
[Tue Mar 01 08:52:22.938712 2016] [mpm_winnt:notice] [pid 6748:tid 544] AH00456: Apache Lounge VC11 Server built: Oct 13 2015 10:54:13
[Tue Mar 01 08:52:22.938712 2016] [core:notice] [pid 6748:tid 544] AH00094: Command line: 'C:\\laragon\\bin\\apache\\apache-2.4.17/bin/httpd -d C:/laragon/bin/apache/apache-2.4.17'
[Tue Mar 01 08:52:22.939695 2016] [mpm_winnt:notice] [pid 6748:tid 544] AH00418: Parent: Created child process 3672
[Tue Mar 01 08:52:23.214917 2016] [ssl:warn] [pid 3672:tid 532] AH01909: www.example.com:8443:0 server certificate does NOT include an ID which matches the server name
[Tue Mar 01 08:52:23.296629 2016] [ssl:warn] [pid 3672:tid 532] AH01909: www.example.com:8443:0 server certificate does NOT include an ID which matches the server name
[Tue Mar 01 08:52:23.306647 2016] [mpm_winnt:notice] [pid 3672:tid 532] AH00354: Child: Starting 64 worker threads.
[Tue Mar 01 08:52:24.159843 2016] [mpm_winnt:notice] [pid 6748:tid 544] AH00428: Parent: child process 3672 exited with status 3221225725 -- Restarting.
[Tue Mar 01 08:52:24.305896 2016] [ssl:warn] [pid 6748:tid 544] AH01909: www.example.com:8443:0 server certificate does NOT include an ID which matches the server name
[Tue Mar 01 08:52:24.315916 2016] [mpm_winnt:notice] [pid 6748:tid 544] AH00455: Apache/2.4.17 (Win32) OpenSSL/1.0.2d PHP/5.6.16 configured -- resuming normal operations
[Tue Mar 01 08:52:24.315916 2016] [mpm_winnt:notice] [pid 6748:tid 544] AH00456: Apache Lounge VC11 Server built: Oct 13 2015 10:54:13
[Tue Mar 01 08:52:24.315916 2016] [core:notice] [pid 6748:tid 544] AH00094: Command line: 'C:\\laragon\\bin\\apache\\apache-2.4.17/bin/httpd -d C:/laragon/bin/apache/apache-2.4.17'
[Tue Mar 01 08:52:24.317905 2016] [mpm_winnt:notice] [pid 6748:tid 544] AH00418: Parent: Created child process 3600
[Tue Mar 01 08:52:24.580068 2016] [ssl:warn] [pid 3600:tid 552] AH01909: www.example.com:8443:0 server certificate does NOT include an ID which matches the server name
[Tue Mar 01 08:52:24.666114 2016] [ssl:warn] [pid 3600:tid 552] AH01909: www.example.com:8443:0 server certificate does NOT include an ID which matches the server name
[Tue Mar 01 08:52:24.675120 2016] [mpm_winnt:notice] [pid 3600:tid 552] AH00354: Child: Starting 64 worker threads.
推荐答案
这个问题最终通过 Apache 的配置更改得到解决.
This issue was finally resolved with a configuration change with Apache.
将以下内容添加到 httpd.conf 文件:
Add the following to the httpd.conf file:
<IfModule mpm_winnt_module>
ThreadStackSize 8888888
</IfModule>
然后重新启动.
问题是默认情况下,Windows 的堆栈大小比 Linux/Unix 系统上的小.我花了一段时间才弄清楚这一点.Apache 无声无息地崩溃了,我的日志中没有出现任何错误,因此很难追踪.
The problem is that windows has a smaller stack size by default than on the Linux/Unix systems. It took me a while to figure this out. Apache was silently crashing and I was getting no errors in my logs making it hard to trace.
我正在处理的项目有大量的正则表达式调用,显然这是导致 Windows 上 apache 出现此问题的已知触发器.如果您查看 apache 文档,我们可以将 ThreadStackSize 更新为更接近 8MB 的 Unix/Linux 系统的值.
The project I am working on has large regular expression calls and apparently this was a known trigger to cause this issue with apache on windows. If you look at apache documentation we can update the ThreadStackSize to a value closer to Unix/Linux systems of 8MB.
http://httpd.apache.org/docs/2.2/mod/mpm_common.html#ThreadStackSize
我希望这可以帮助其他人在将 apache 作为本地服务器运行的 Windows 系统上进行开发.一段时间以来,这是一个令人头疼的问题.
I hope this helps anyone else developing on a windows system running apache as a local server. This was a major headache for some time.
这篇关于任何文件更改后 Laravel 连接重置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!