简体   繁体   中英

How to deploy laravel homestead environment

I have built an API using laravel and laravel homestead. 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.

I tried simply deploying the repo to heroku, but that just gives me errors. It always works great for rails, but for laravel I get failures and this is all that's in my logs:

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.

Install laravel homestead on a Windows computer is not that difficult. Just follow the Laravel documentation and add one environment variable. I will also try to explain the steps.

Follow these steps:

1 - First, you need install VirtualBox & Vagrant (please refer 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 "

3 - clone homestead by typing: "git clone https://github.com/laravel/homestead.git Homestead"

4 - Add this path to your environment variables. "C:\\Users\\YourUserName\\AppData\\Roaming\\Composer\\vendor\\bin"

5 - Run "bash init.sh" to generate homestead.yaml file inside your .homestead directory.

6 - Generate ssk key if you haven't already by typing: ssh-keygen -t rsa -C "you@emailaddress.com"

7 - Initialize homestead by typing "homestead init"

8 - Run homestead by typing "homestead up"

Don't forget to add the "domains" for your Nginx sites to the hosts file on your machine! The hosts file will redirect your requests for the local domains into your Homestead environment. On Windows, it is located at 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)

That's all. Good luck

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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