在本地机器上运行Laravel

发布于 2025-02-06 01:00:32 字数 1675 浏览 2 评论 0原文

我正在尝试在本地机器中运行一个Laravel项目。它正常从 http://127.0.0.1:8000 但是当我尝试在浏览器中打开URL时端口更改为8001,而新的URL为 http://127.0.0.0.1.1:8001 。当我尝试在浏览器中打开此问题时,端口再次更改为8002。

图像显示问题

“

composer.json

“”

我的PHP版本是7.4.1。如果其他人早些时候遇到了这个问题,或者知道如何解决此问题,请帮助解决此问题。

谢谢。


更新1: 注意到了什么。每当执行与数据库相关的代码时,此问题就会弹出。例如,当我尝试执行图像中显示的以下代码时,它运行顺利,我可以在浏览器中看到输出。 当代码顺利运行时时,

但是当我将代码更改为以下。 当问题显示时时。这不是数据库重量查询,但是为什么这个问题呢?任何线索都将非常有帮助。


更新2: 在Laravel日志中什么也没有发现,但在Apache错误日志中找到了以下内容,该日志以下给出:

[[Thu Jun 09 21:37:24.988703 2022 2022]] [MPM_WINNT:CRIT:CRIT] [PID 2660:TID 704] AH02538:AH02538:CHILD:父亲:父母的父母突然出现。 。儿童进程正在结束

[thu Jun 09 21:37:27.399609 2022] [核心:警告] [PID 8084:TID 576] AH00098:PID文件C:/XAMPPE/APACHE/LOGS/LOGS/HTTTPD.PID。 Apache运行?

[THU JUN 09 21:37:27.446479 2022] [MPM_WINNT:注意

] 2022] [MPM_WINNT:注意]

Thu Jun 09 21:37 :27.446479 核心:注意] [PID 8084:TID 576] AH00094:命令行:'C:\ Xampp \ apache \ bin \ bin \ httpd.exe -d c:/xampp/apache'

[thu Jun 09 Jun 09 21:37:37:27.44444499 2022] [ mpm_winnt:注意] [PID 8084:TID 576] AH00418:父母:创建的子进程10064

[THU JUN 09 21:37:28.196453 2022] [MPM_WINNT: 注意:注意: 。

I am trying to run a laravel project in my local machine. It starts normally on http://127.0.0.1:8000 but when I try to open the url in the browser the port changes to 8001 and the new url is http://127.0.0.1:8001. When I try to open this in the browser, again the port changes to 8002.

Image showing the issue

composer.json

My PHP version is 7.4.1. If anyone else faced this issue earlier or knows how to fix this issue, please help in fixing this issue.

Thank you.


Update 1:
Noticed something. Whenever database related code is executed, this issue is popping up. For example, when I try to execute the following code shown in the image, it runs smoothly and I can see the output in the browser. Case when the code runs smoothly

But when I change the code to the following, the issue shows up.
Case when the issue shows up. This is not any database heavy query but why this issue? Any leads would be very helpful.


Update 2:
Found nothing in laravel logs but found the following in the apache error log which is given below:

[Thu Jun 09 21:37:24.988703 2022] [mpm_winnt:crit] [pid 2660:tid 704] AH02538: Child: Parent process exited abruptly. Child process is ending

[Thu Jun 09 21:37:27.399609 2022] [core:warn] [pid 8084:tid 576] AH00098: pid file C:/xampp/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?

[Thu Jun 09 21:37:27.446479 2022] [mpm_winnt:notice] [pid 8084:tid 576] AH00455: Apache/2.4.41 (Win64) OpenSSL/1.1.1c PHP/7.4.1 configured -- resuming normal operations

[Thu Jun 09 21:37:27.446479 2022] [mpm_winnt:notice] [pid 8084:tid 576] AH00456: Apache Lounge VC15 Server built: Aug 11 2019 12:20:04

[Thu Jun 09 21:37:27.446479 2022] [core:notice] [pid 8084:tid 576] AH00094: Command line: 'c:\xampp\apache\bin\httpd.exe -d C:/xampp/apache'

[Thu Jun 09 21:37:27.446479 2022] [mpm_winnt:notice] [pid 8084:tid 576] AH00418: Parent: Created child process 10064

[Thu Jun 09 21:37:28.196453 2022] [mpm_winnt:notice] [pid 10064:tid 664] AH00354: Child: Starting 150 worker threads.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无悔心 2025-02-13 01:00:33

尝试此参数,我认为帮助您

php artisan serve --port=8080

Try this parameter I think help you

php artisan serve --port=8080
夏有森光若流苏 2025-02-13 01:00:33

这可能是代码的问题,您已经写了,而不是laravel问题。我以前很久以前就遇到过这样的问题,因此您可以检查:

  • 代码正在刀片或控制器中处理。
  • 或者这可能是与PC相关的内存问题(可能与此问题有关,但是当我患有低端PC并且所有这些问题都在发生时,我遇到了很多记忆问题。

)第一个猜测是代码,因此您可能需要共享代码发现,正在发生的事情。

而且,无论如何,保留端口中的冲突也将避免,例如,如果将本地环境服务器设置为其他东西(8080),则将再次发生同样的问题。

而且,如果您关闭终端而没有关闭本地环境,那么新PHP Artisan服务无论如何都会运行本地环境,例如,我的终端/IDE已关闭,但申请正在服务,并且执行php Artisan Serve不强迫我关闭并运行像您这样的新的本地环境,它试图再次服务,但是老一人正在发生冲突。

因此,正如我再次说的那样,这可能是一个代码问题。

仔细检查您的代码或共享以找到问题。

This highly, might be a problem to the code, you've write-ed, not a Laravel problem. I've faced issues like this before for a long time ago, so you might check :

  • The code is processing in blade or controller.
  • Or it might be a memory issues related to PC (might not be, related to this issue, but i had a lots of memory issues back then when i had low-end PC and all these issues was happening.)

As I said, my first guess is the code, so you might need to share the code find out, what is happening.

Also conflicts in reserved ports will be avoided anyway, for example if you set your local environment server to something else(8080), same issue will happen again.

And sometime if you close your terminal without closing local environment, new php artisan serve will run the local environment anyway, for example, my terminal/IDE was closed but application was serving, and doing php artisan serve not forced me to close and run a new local environment like yours, it was trying to serve again, but old one was doing conflicts.

So as I said again, it might be a code issue.

Double check your code or share it to find the issue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文