laravel 为 php artisan.php serve 设置端口
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17990820/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Set port for php artisan.php serve
提问by maan81
How do we set a custom port for test server?
我们如何为测试服务器设置自定义端口?
Normally when we do
通常当我们做
php artisan serve
the folder gets served as :
该文件夹被用作:
localhost:8000
How do could we access one folder as:
我们如何访问一个文件夹:
localhost:8080
I want to access two different development sites on my localhost.
我想在我的本地主机上访问两个不同的开发站点。
回答by Andreas Bergstr?m
For port 8080:
对于端口 8080:
php artisan serve --port=8080
And if you want to run it on port 80, you probably need to sudo:
如果你想在端口 80 上运行它,你可能需要 sudo:
sudo php artisan serve --port=80
回答by Ahmed Mahmoud
as this example you can change ip and port this works with me
作为这个例子,你可以改变 ip 和 port 这对我有用
php artisan serve --host=0.0.0.0 --port=8000
回答by Rob Gordijn
One can specify the port with: php artisan serve --port=8080
.
可以使用以下命令指定端口:php artisan serve --port=8080
。
回答by Shabeer Sha
You can use many ports together for each project,
您可以为每个项目一起使用多个端口,
php artisan serve --port=8000
php artisan serve --port=8001
php artisan serve --port=8002
php artisan serve --port=8003
回答by Derrek Bertrand
Andreas' answer above was helpful in solving my problem of how to test artisan on port 80. Port 80 can be specified like the other port numbers, but regular users do not have permissions to run anything on that port.
上面 Andreas 的回答有助于解决我如何在端口 80 上测试 artisan 的问题。可以像其他端口号一样指定端口 80,但普通用户无权在该端口上运行任何内容。
Drop a little common sense on there and you end up with this for Linux:
在那里放下一点常识,你最终会在 Linux 上得到这个:
sudo php artisan serve --port=80
This will allow you to test on localhost without specifying the port in your browser. You can also use this to set up a temporary demo, as I have done.
这将允许您在 localhost 上进行测试,而无需在浏览器中指定端口。您也可以使用它来设置临时演示,就像我所做的那样。
Keep in mind, however, that PHP's built in server is not designed for production. Use nginx/Apache for production.
但是请记住,PHP 的内置服务器不是为生产设计的。使用 nginx/Apache 进行生产。
回答by vishal pardeshi
You can use
您可以使用
php artisan serve --port 80
Works on Windows platform
适用于 Windows 平台
回答by Dr Tyrell
sudo /Applications/XAMPP/xamppfiles/bin/apachectl start
This fixed my issue AFTER ensuring my ports were all uniquely sorted out.
这解决了我在确保我的端口都被唯一排序后的问题。
回答by Ashish v
you can also add host as well with same command like :
您还可以使用相同的命令添加主机,例如:
php artisan serve --host=172.10.29.100 --port=8080
回答by Thilina Dharmasena
when we use the
当我们使用
php artisan serve
it will start with the default HTTP-server port mostly it will be 8000
when we want to run the more site in the localhost we have to change the port. Just add the --port argument:
它将从默认的 HTTP 服务器端口开始,主要是8000
当我们想要在本地主机中运行更多站点时,我们必须更改端口。只需添加 --port 参数:
php artisan serve --port=8081