Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access a Laravel site from another machine on the same network?

I have a Laravel site on my computer which I can access by typing the php artisan serve command. However I cannot access the site from another machine on the same network.

Is there a way to access the site from another machine?

like image 279
captainblack Avatar asked Dec 13 '16 07:12

captainblack


1 Answers

Yes there is! There are two ways to go about it.

Method 1: Passing a Host Parameter to Artisan

First figure out your computer IP address. If you are on Linux or Mac, type ifconfig at the terminal. If you are on Windows, type ipconfig at the command prompt.

Then, go to your Laravel root directory and just type:

php artisan serve --host=XX.XX.XX.XX

If you'd also like to pass the port parameter, just add --port=XX to the artisan serve command.

Method 2: Serving via a Webserver (like Apache)

Setup Laravel inside your Apache webserver directory through composer. Navigate to your laravel directory and set permissions of the storage folder to 777 by typing this command at the terminal: sudo chmod -R 777 storage/

Access your Laravel site by navigating to

http://IPADDR/laravelproject/public

And voila!

like image 144
captainblack Avatar answered Nov 12 '22 15:11

captainblack