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?
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!
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