【问题标题】:Serve multiple laravel apps on localhost with php artisan serve使用 php artisan serve 在 localhost 上提供多个 laravel 应用程序
【发布时间】:2019-10-10 13:45:23
【问题描述】:

我希望能够在不同的选项卡/端口上同时提供多个 laravel 应用程序,这样我就可以展示各种设计,可悲的是,当我运行 php artisan serve 时,我只能运行一个应用程序一次在 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.

我有什么遗漏的吗?

【问题讨论】:

  • 你绝对只能在一个端口上运行一个服务器。我会考虑通过 Apache 之类的东西运行您的网站,XAMPP 很容易设置,并允许在 localhost 上运行多个 Laravel 站点
  • 您也可以尝试访问 localhost 上的其他端口,因此请尝试 localhost/yourLaravelSite:8001 最高 8009 以查看它是否在那里运行

标签: php laravel


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    您可以在运行php artisan serve 时添加--port ####,如下所示:

    php artisan serve --port 8001,这将在端口 8001 上运行您的项目

    【讨论】:

    • 我用这个,但是在 apache laravel 项目中它只能在端口 80 上工作。我不能在不同的项目上运行多个 laravel 项目。
    【解决方案3】:

    您可以为此使用 Laravel Valet,基本上每个站点都有本地域,如果您在 Windows 上,我每天都会在 MacOS 上使用它,这应该会有所帮助:

    https://github.com/cretueusebiu/valet-windows

    【讨论】:

      【解决方案4】:

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

      【讨论】:

        猜你喜欢
        • 2016-07-25
        • 2015-12-27
        • 2018-02-22
        • 2017-08-02
        • 2016-11-25
        • 2016-04-24
        • 1970-01-01
        • 2019-07-07
        • 2019-07-20
        相关资源
        最近更新 更多