简体   繁体   English

如何部署Laravel宅基地环境

[英]How to deploy laravel homestead environment

I have built an API using laravel and laravel homestead. 我已经使用laravel和laravel homestead构建了一个API。 I am now looking for the easiest way to host it online, so that I can consume the API with a mobile app I'm working on. 我现在正在寻找最简单的在线托管方式,以便可以通过正在使用的移动应用程序使用该API。

I tried simply deploying the repo to heroku, but that just gives me errors. 我尝试仅将回购部署到heroku,但这给了我错误。 It always works great for rails, but for laravel I get failures and this is all that's in my logs: 它始终适用于rails,但是对于laravel来说我会失败,这就是我的日志中的全部内容:

2015-03-10T01:56:53.074222+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/api/v1/users?token=1234" host=selfiesnap-api.herokuapp.com request_id=07dbc670-2775-45a6-995f-900e51c0854b fwd="68.56.144.126" dyno= connect= service= status=503 bytes=

Since everything is already in a contained, vagrant environment (homestead), I was hoping there would be a more straightforward way to launch the API into a hosted environment. 由于所有内容都已经在一个封闭的,无所事事的环境(宅基地)中,我希望可以有一种更直接的方法将API启动到托管环境中。

Install laravel homestead on a Windows computer is not that difficult. 在Windows计算机上安装laravel homestead并不困难。 Just follow the Laravel documentation and add one environment variable. 只需遵循Laravel文档并添加一个环境变量即可。 I will also try to explain the steps. 我还将尝试解释这些步骤。

Follow these steps: 跟着这些步骤:

1 - First, you need install VirtualBox & Vagrant (please refer laravel docs ) 1-首先,您需要安装VirtualBox&Vagrant(请参阅laravel docs)

2 - Add box by typing "vagrant box add laravel/homestead" (If this command fails, you may have an old version of Vagrant that requires the full URL: "vagrant box add laravel/homestead https://atlas.hashicorp.com/laravel/boxes/homestead " 2-通过键入“ vagrant box add laravel / homestead”添加框(如果此命令失败,则您可能具有要求完整URL的Vagrant旧版本:“ vagrant box add laravel / homestead https://atlas.hashicorp.com / laravel / boxes / homestead

3 - clone homestead by typing: "git clone https://github.com/laravel/homestead.git Homestead" 3-通过键入以下内容来克隆Homestead:“ git clone https://github.com/laravel/homestead.git Homestead”

4 - Add this path to your environment variables. 4-将此路径添加到环境变量。 "C:\\Users\\YourUserName\\AppData\\Roaming\\Composer\\vendor\\bin" “ C:\\ Users \\ YourUserName \\ AppData \\ Roaming \\ Composer \\ vendor \\ bin”

5 - Run "bash init.sh" to generate homestead.yaml file inside your .homestead directory. 5-运行“ bash init.sh”以在.homestead目录中生成homestead.yaml文件。

6 - Generate ssk key if you haven't already by typing: ssh-keygen -t rsa -C "you@emailaddress.com" 6-如果尚未输入,请生成ssk密钥:ssh-keygen -t rsa -C“ you@emailaddress.com”

7 - Initialize homestead by typing "homestead init" 7-通过键入“ homestead init”来初始化homestead

8 - Run homestead by typing "homestead up" 8-输入“宅基地向上”运行宅基地

Don't forget to add the "domains" for your Nginx sites to the hosts file on your machine! 不要忘记将Nginx站点的“域”添加到计算机上的hosts文件中! The hosts file will redirect your requests for the local domains into your Homestead environment. hosts文件会将您对本地域的请求重定向到您的Homestead环境中。 On Windows, it is located at C:\\Windows\\System32\\drivers\\etc\\hosts. 在Windows上,它位于C:\\ Windows \\ System32 \\ drivers \\ etc \\ hosts。 The lines you add to this file will look like the following: 您添加到此文件的行将如下所示:

192.168.10.10 homestead.app (if 192.168.1.1 is not working, try 127.0.0.1) 192.168.10.10 homestead.app(如果192.168.1.1无法正常工作,请尝试127.0.0.1)

That's all. 就这样。 Good luck 祝好运

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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