Serve multiple laravel apps on localhost with php artisan serve - php

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?

Use php artisan serve --port='YOUR-PORT' command.
or
you can create a variable SERVER_PORT in your .env file
Example:
SERVER_PORT=80

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

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

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

Related

php artisan serve vs. npm run dev - difference between both servers?

I just started to learn more about Laravel and I am confused about servers. When I run 'php artisan serve' in my project's folder, I can access my web project via localhost:8000. When I run npm run dev I can access via localhost:5173 - but I am not directed to my web project's landing page but to the welcome page of Laravel Vite. For me running 'php artisan serve' is the right option. So, now to my question(s): Did I do some kind of misconfiguration when setting up the project? Where is the difference between those two servers? Thank you for your answers! Robert
Php artisan serve - hosts your project on your local server. And 'npm run dev' command complies vite and it will track and update frontend modifications without reload.

how can run websockets:serve on hosting laravel

Work on a laravel site with real-time notifications using the laravel-websocket library from:
https://beyondco.de/docs/laravel-websockets/getting-started/introduction
On the local server I have to run the following command for it to work:
php artisan websockets:serve
Starting the WebSocket server on port 6001...
Now I have uploaded the website to cloudways hosting
How can I implement the command to always run the server?
php artisan websockets:serve
If you are using VPS, I think you should install a supervisor to help out running your WebSocket. Here example that I found click

Laravel 7.28 not work without php artisan serve command in localhost

Laravel 7.28 not work without php artisan serve command in localhost
I install new Laravel in localhost (/var/www/html/NewLaravel)
When I run http://localhost/NewLaravel/public/ not workling
but when I run with php artisan serve its working on http://127.0.0.1:8000/
Apache2 is working proper and allow access of override for .htaccess
is that new Laravel will only work with php artisan serve ?? or something is missing from my side ?
Step-1:
run apache and sql from xampp server
step-2:
in browser type localhost/NewLaravel and press enter
Step-3:
in list please select public folder it will run

How to make artisan serve work in virtual host?

I'm on Windows 8 and I'm using WAMP to run my laravel project. I have configured apache and I created a virtual host, to access my app through http://myapp.dev.
I would like to know if it's possible to use the built-in php server (to run the laravel aplication through artisan serve) to point to my virtualhost instead of http://localhost:8000.
I tried to change the app url in app.php but it didn't work.
Point myapp.dev to 127.0.0.1 in your hosts file, and do php artisan serve --host 0.0.0.0 --port 80.
In Linux/OSX, this requires sudo privilege, I'm not sure what Windows will require. You'd want to stop Apache too, as it uses port 80 and will cause a conflict if both are trying to run on that port.
You need change the hosts file (ubuntu => /etc/hosts, windows => $WINDIR/System32/drivers/etc/hosts).
127.0.0.1 myapp.dev
.env file also needs changing:
APP_URL=tttp://myapp.dev:8000
$ php artisan serve --host=myapp.dev

How to run laravel 5 on port 80 of localhost?

For previous versions of Laravel, you can simply download laravel with composer in the root folder of your apache server and type in http://localhost/public/ to see the "You've arrived" homepage.
I know I can use php artisan serve to view the Laravel5 default home page, but it is run on localhost:8000 and I heard that php artisan serve command should not be used in production due to the limit of connection and the bad performance. Is there a way I can see the default home page without using the php artisan serve command?
And it is really frustrating that Laravel is not including such simple thing in their installation documentation....
To run the service on another port you need to pass the port parameter with port numberusing this code on the cmd:
php artisan serve --port=80
To run on port 80, you might need administrator permission.
You may have to use sudo command for admin rights.
sudo php artisan serve --port=80

Categories