简体   繁体   中英

Command php artisan serve on other network?

I know that when i run this command:

php artisan serve --host=localhost

It works when other computer is on same network, but if someone from other network wanna access it is it possible? Im asking that because i can not check at the moment.

Apart from setting correct rules for firewall and router you need to run the command with a reacheble host, ie:

php artisan serve --host 0.0.0.0

or better to be explicit with your IP address

php artisan serve --host YOUR_IP_HERE

On Ubuntu 18 in Virtualbox I just needed

sudo ufw allow 8000

for the additional firewall rule and then

php artisan serve --host=_your_ip_address

Now it works on every device in the network.

Thanks to this Laracast Discussion .

有时php artisan serve may fail您可以只使用内置的php服务器,例如php -S <ip-to-remote-serve>:<port> -t public public/index.php

php -S 192.168.100:8000 -t public public/index.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM