Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a domain name with php artisan serve

Tags:

I am new to PHP and Laravel. While virtualhosting with Wamp, I could specify the documentroot, servername and the port number - hence specifying the domain name. But with the command php artisan serve, I am able to specify the port address but not the domain name. Is it possible to set the domain name?

also, what is the difference between hosting with this command and with wamp ?

n.b I am new to server side languages, sorry for asking these basics !

EDIT: I've used php artisan serve --host=blog.local --port=8001 but error is showing upenter image description here

I've cleared the configuration and application cache.

like image 652
Proteeti Prova Avatar asked May 22 '18 06:05

Proteeti Prova


People also ask

Can php artisan serve?

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.

How do I change my localhost domain to Laravel?

It's located at /etc/hosts on Mac or Linux alternatively you can find it at C:\Windows\System32\drivers\etc\hosts on Windows. You will need administrator rights to change this. You can change the something.com to the domains you want to use.

How do I change the port of an artisan serve in php?

To set the "php artisan serve" command port number to anything other than 8080 you can specify the port number using the "--port" flag and then specify the port number.

What is php artisan command?

Artisan is the name of the command-line interface included with Laravel. It provides a number of helpful commands for your use while developing your application. It is driven by the powerful Symfony Console component.


2 Answers

You can explicitly define the host and the port with artisan serve command:

php artisan serve --host=somedomain.com --port=8001

Note: Remember to enable to port with your firewall.

like image 99
Saurabh Avatar answered Oct 11 '22 09:10

Saurabh


Though it is too late.

Make an entry in the system host file. in case of windows it is at

C:\Windows\System32\Drivers\etc\hosts

 # localhost name resolution is handled within DNS itself. #   127.0.0.1       localhost #   ::1             localhost 127.0.0.1           blog.local  

Then run your command:

php artisan serve --host=blog.local --port=8001 
like image 41
Srijib Mandal Avatar answered Oct 11 '22 09:10

Srijib Mandal