为 php artisan.php 服务设置端口 [英] Set port for php artisan.php serve
问题描述
我们如何为测试服务器设置自定义端口?
How do we set a custom port for test server?
一般情况下
php artisan serve
文件夹被用作:
localhost:8000
我们如何访问一个文件夹:
How do could we access one folder as:
localhost:8080
我想在我的本地主机上访问两个不同的开发站点.
I want to access two different development sites on my localhost.
推荐答案
Laravel 5.8 到 8.0 及以上
只需将其作为参数传递:
Laravel 5.8 to 8.0 and above
Simply pass it as a paramter:
php artisan serve --port=8080
您还可以通过以下方式绑定到特定主机:
You may also bind to a specific host by:
php artisan serve --host=0.0.0.0 --port=8080
或者(对于 Laravel 6+)您可以通过在 .env 文件中设置 SERVER_PORT 和 SERVER_HOST 来提供默认值.您可能还需要执行 php artisan cache: clear .(感谢@mohd-samgan-khan)
Or (for Laravel 6+) you can provide defaults by setting SERVER_PORT and SERVER_HOST in your .env file. You might need to do php artisan cache: clear as well. (thanks @mohd-samgan-khan)
如果你想在80端口上运行它,你可能需要sudo.
And if you want to run it on port 80, you probably need to sudo.
这篇关于为 php artisan.php 服务设置端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!