我在本地环境(Windows 10)中安装了laravel 4.2进行测试,但在更新任何文件后仍然出现连接重置错误。
我的项目将加载,服务器正确显示我的页面。但是,如果我更新文件(例如索引)然后尝试访问呈现新更新文件的页面,我总是会遇到连接重置错误。甚至像一个时期一样简单的变化。
更有趣的是当我使用 php artisan 来提供我的文件时,我从来没有遇到连接重置问题。如果我通过工匠服务访问该页面它是有效的,然后突然xampp想要工作,但只有在我之前从工匠加载页面之后。
如果我再次对文件进行更改,我必须重复此过程。
本地设置
我的项目是从xampp(v 3.2.2)本地托管的,具有以下v-hosts配置。主机文件也已正确配置。
<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上重置了连接。我从artisan查看页面,然后在xampp上刷新页面,突然它起作用。
更新
我已经尝试过Lucas建议的替代品,例如laragon,但同样的错误仍然存在。在尝试访问该页面时更新任何文件后,我收到连接重置错误。
我在laragon中找到了更多关于apache日志的信息。
[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.
答案 0 :(得分:2)
最后通过Apache的配置更改解决了这个问题。
将以下内容添加到 httpd.conf 文件中:
<select id="chooser">
<option value="#apple">I really like apples</option>
<option value="#orange">Give me an orange any day</option>
<option value="#grape">Grapes are the best</option>
</select>
<div id="apple">
Let me talk to you about Apples.
</div>
<div id="orange">
Let me talk to you about Oranges.
</div>
<div id="grape">
Let me talk to you about Grapes.
</div>
<script type="text/javascript">
$(function () {
$(document).on("click", "a[href^='#']", function () {
event.preventDefault();
$('html,body').animate({ scrollTop: $(this.hash).offset().top }, 500);
});
});
</script>
然后重启。
问题是Windows默认的堆栈大小比Linux / Unix系统小。我花了一段时间来弄明白这一点。 Apache无声地崩溃,我的日志中没有任何错误,因此很难跟踪。
我正在处理的项目有大型的正则表达式调用,显然这是一个已知的触发器,在Windows上导致apache这个问题。如果你看一下apache文档,我们可以将 ThreadStackSize 更新为更接近 8MB 的Unix / Linux系统的值。
http://httpd.apache.org/docs/2.2/mod/mpm_common.html#ThreadStackSize
我希望这有助于在运行apache的Windows系统上开发的任何其他人作为本地服务器。一段时间以来,这是一个令人头疼的问题。
答案 1 :(得分:1)
php artisan serve
使用构建在服务器上的PHP(php -S localhost:80 -t public
)来托管应用程序。
也许问题可能是你的apache配置,所以试试这个:
# define DOCROOT variable
define DOCROOT "C:/xampp/htdocs"
<Directory "${DOCROOT}">
AllowOverride All
Require all granted
</Directory>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/myproject/public/"
ServerName myproject.dev
</VirtualHost>
如果问题仍然存在,请尝试使用Laragon并始终以管理员身份打开它。
答案 2 :(得分:0)
打开php错误日志可能会帮助您找到真正的问题。我的代码出错(直接在函数上使用isset())