I am running php artisan serve
command
by default the result is :
Laravel development server started: http://127.0.0.1:8000
I want to change pointing to other ip
# php artisan serve --help
Usage:
serve [options]
Options:
--host[=HOST] The host address to serve the application on. [default: "127.0.0.1"]
--port[=PORT] The port to serve the application on. [default: 8000]
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--env[=ENV] The environment the command should run under
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Help:
Serve the application on the PHP development server
To change default host and/or port for the artisan serve command, you need to edit the ServeCommand.php file:
$ sudo nano vendor/laravel/framework/src/Illuminate/Foundation/Console/ServeCommand.php
At the end of it you will find were they are configured:
protected function getOptions()
{
return [
['host', null, InputOption::VALUE_OPTIONAL, 'The host address to serve the application on', '127.0.0.1'],
['port', null, InputOption::VALUE_OPTIONAL, 'The port to serve the application on', '8000'],
];
}
Just change de default value of the host 127.0.0.1 for the ip of your desired host. And 8000 for the number of your desired port.
My case: I have an UbuntuServer 18.04 VM running over GoogleCloud - ComputeEngine, I was unable to see the Laravel execution until I changed the host to 0.0.0.0, of course I changed the port as well to have the 80 as default.
The alternative was executing every time:
$ sudo php artisan serve --host=0.0.0.0 --port=80
in order to obtain the same result.
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