4

I'd like to be able to serve more than one laravel app at the same time on different tabs/ports, this is so I can showcase various designs, sadly when I run php artisan serve I can get only one app running at a time on port 8000.

Even after updating to laravel 5.8, form the docs:

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.

Is there anything I'm missing?

gabogabans
  • 3,035
  • 5
  • 33
  • 81
  • You can definitely only run one server on a single port. I would look at running your site through something like Apache, XAMPP is pretty easy to set up and allows for running multiple Laravel sites on localhost – Grant C. May 24 '19 at 00:38
  • Also you could try accessing a different port on localhost, so try `localhost/yourLaravelSite:8001` up to 8009 to see if it's running there – Grant C. May 24 '19 at 00:39
  • https://stackoverflow.com/a/72043591/7186739 – Billu Apr 28 '22 at 12:22

4 Answers4

9

Use php artisan serve --port='YOUR-PORT' command.

or

you can create a variable SERVER_PORT in your .env file

Example:

SERVER_PORT=80
5

you can add --port #### when you run php artisan serve like this:

php artisan serve --port 8001, this will run your project on port 8001

Kapitan Teemo
  • 2,144
  • 1
  • 11
  • 25
  • I use this , but in apache laravel projects it works only on port 80. I cannot run multiple laravel projects on different proejcts. – Eranda Peiris Jan 20 '21 at 04:39
2

You can use Laravel Valet for this, you essentially have local domains for each site, I use it daily on MacOS if you're on windows this should help:

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

Dave
  • 878
  • 8
  • 19
1

Run php artisan serve --port port_number this will run your project on your defined port.