使用php artisan serve在本地主机上提供多个laravel应用程序

qxgroojn  于 2023-01-21  发布在  PHP
关注(0)|答案(4)|浏览(173)

我希望能够同时在不同的标签/端口上提供多个laravel应用程序,这样我就可以展示各种设计,遗憾的是,当我运行php工匠服务时,我只能在端口8000上同时运行一个应用程序。
即使在更新到laravel 5.8后,也要形成文档:

Artisan Serve Improvements
In previous releases of Laravel, Artisan's serve command would serve your application on port  8000. If another serve command process was already listening on this port, an attempt to serve a second application via serve would fail. Beginning in Laravel 5.8, serve will now scan for available ports up to port 8009, allowing you to serve multiple applications at once.

有什么我错过了吗?

z9gpfhce

z9gpfhce1#

使用php artisan serve --port ='YOUR-PORT'命令。

可以在.env文件中创建变量SERVER_PORT
示例:

SERVER_PORT=80
ghg1uchk

ghg1uchk2#

当你运行php artisan serve时,你可以添加--port ####,如下所示:
php artisan serve --port 8001,这将在端口8001上运行项目

w7t8yxp5

w7t8yxp53#

你可以使用Laravel Valet,你基本上有每个网站的本地域名,我每天都在MacOS上使用它,如果你在Windows上,这应该会有帮助:
https://github.com/cretueusebiu/valet-windows

ws51t4hk

ws51t4hk4#

运行php artisan serve --port port_number这将在您定义的端口上运行您的项目。

相关问题