Laravel Homestead vhost 配置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25268411/
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
Laravel Homestead vhost configuration
提问by Alexander Cogneau
I am using Laravel homestead. For a project I need a special vhost configuration, where should I define this?
我正在使用 Laravel 宅基地。对于一个项目,我需要一个特殊的 vhost 配置,我应该在哪里定义它?
回答by Swader
You add a new folder mapping into the "sites" block of Homestead.yml, like so:
您将一个新的文件夹映射添加到 Homestead.yml 的“站点”块中,如下所示:
- map: myapp.com
to: /home/vagrant/Code/myapp/public
That's all there is to adding a new vhost. To modify it, edit the appropriate file in /etc/nginx/sites-available
. In the above case, this would be /etc/nginx/sites-available/myapp.com
这就是添加新虚拟主机的全部内容。要修改它,请在/etc/nginx/sites-available
. 在上述情况下,这将是/etc/nginx/sites-available/myapp.com
See herefor example customization of a newly added vhost. Note that the quick tip linked here uses Homestead Improved, a slightly enhanced version of Homestead, as described here.
请参见此处,例如自定义新添加的虚拟主机。请注意,快速提示链接在这里使用宅基地改进,稍微增强家园的版本,描述在这里。
More Homestead related posts can be found on our site via the Homestead tag.
更多与 Homestead 相关的帖子可以在我们的网站上通过Homestead 标签找到。
回答by smarques
I have been looking for a solution for customizing nginx vhosts. You want to do it in provisioning, or better: after provisioning otherwise Homestead will overwrite any changes you have done manually to the vhost files.
我一直在寻找自定义 nginx vhosts 的解决方案。您希望在配置中进行,或者更好:配置后,否则 Homestead 将覆盖您手动对 vhost 文件所做的任何更改。
One solution is the one I found here: https://laracasts.com/discuss/channels/requests/homestead-provision-deletes-custom-nginx-settings
一种解决方案是我在这里找到的:https: //laracasts.com/discuss/channels/requests/homestead-provision-deletes-custom-nginx-settings
Basically you create configuration files in a folder in the host machine, map that extra folder to the vagrant machine, then in your after.sh file (which is run by homestead after the normal provisioning is finished) you just copy all of them to nginx's sites_available folder.
基本上,您在主机的文件夹中创建配置文件,将该额外文件夹映射到流浪机器,然后在您的 after.sh 文件(在正常配置完成后由 homestead 运行)中,您只需将它们全部复制到 nginx 的sites_available 文件夹。