如何使用 php artisan serve 设置域名
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/50460833/
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
How to set a domain name with php artisan serve
提问by Proteeti Prova
I am new to PHP and Laravel. While virtualhosting with Wamp, I could specify the documentroot, servername and the port number - hence specifying the domain name. But with the command php artisan serve, I am able to specify the port address but not the domain name. Is it possible to set the domain name?
我是 PHP 和 Laravel 的新手。在使用 Wamp 进行虚拟主机时,我可以指定文档根目录、服务器名称和端口号 - 因此指定域名。但是使用 php artisan serve 命令,我可以指定端口地址而不是域名。可以设置域名吗?
also, what is the difference between hosting with this command and with wamp ?
另外,使用此命令托管和使用 wamp 托管有什么区别?
n.b I am new to server side languages, sorry for asking these basics !
nb 我是服务器端语言的新手,很抱歉问这些基础知识!
EDIT: I've used php artisan serve --host=blog.local --port=8001 but error is showing up
编辑:我使用过 php artisan serve --host=blog.local --port=8001 但出现错误
I've cleared the configuration and application cache.
我已经清除了配置和应用程序缓存。
回答by Saurabh
You can explicitly define the host and the port with artisan serve command:
您可以使用 artisan serve 命令明确定义主机和端口:
php artisan serve --host=somedomain.com --port=8001
php artisan serve --host=somedomain.com --port=8001
Note: Remember to enable to port with your firewall.
注意:请记住启用与防火墙的端口。
回答by mayank
It's easy, just pass the --host
parameter.
很简单,传入--host
参数即可。
php artisan serve --host=example.com
回答by srijib
Though it is too late.
虽然为时已晚。
Make an entry in the system host file. in case of windows it is at
在系统主机文件中创建一个条目。如果是窗户,它在
C:\Windows\System32\Drivers\etc\hosts
C:\Windows\System32\Drivers\etc\hosts
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 blog.local
Then run your command:
然后运行你的命令:
php artisan serve --host=blog.local --port=8001
回答by V? Nguy?n
Try to command like this:
尝试这样命令:
php artisan serve --host=<host IP address> --port=<port to use>
Example:
例子:
php artisan serve --host=127.0.0.1 --port=8080