How do we set a custom port for test server?
Normally when we do
php artisan serve
the folder gets served as :
localhost:8000
How do could we access one folder as:
localhost:8080
I want to access two different development sites on my localhost.
We can run the laravel project using "php artisan serve" command. It will use by default 8000 port to run the laravel app. But you want to run laravel project on a different port then the artisan command provides an option called "--port" and you can run the laravel app in a different port.
Normally, the development server of the Laravel runs on port 8000 , which can be accessed from http://localhost:8000.
In Laravel, we can run Laravel Development server by typing php artisan serve command on terminal or command line. Make sure your in Laravel's project root directory. If not change your present working directory.
The Laravel PHP artisan serve command helps running applications on the PHP development server. As a developer, you can use Laravel artisan serve to develop and test various functions within the application. It also accepts two additional options. You can use the host for changing application's address and port.
Simply pass it as a paramter:
php artisan serve --port=8080
You may also bind to a specific host by:
php artisan serve --host=0.0.0.0 --port=8080
Or (for Laravel 6+) you can provide defaults by setting SERVER_PORT and SERVER_HOST in your .env file. You might need to do php artisan cache: clear as well. (thanks @mohd-samgan-khan)
And if you want to run it on port 80, you probably need to sudo.
as this example you can change ip and port this works with me
php artisan serve --host=0.0.0.0 --port=8000
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With