I am new on vagrant. I am using Laravel Homestead Improved by following this
link. I want to map my existing code on vagrant which is inside my xampp installation. Here is my Homestead.yaml file contents.
ip: "192.168.10.10"
memory: 2048
cpus: 1
sites:
- map: myapp.com
to: /home/vagrant/Code
folders:
- map: /opt/lampp/htdocs/codebase
to: /home/vagrant/Code
variables:
- key: APP_ENV
value: local
Although when I run the following command
cd Code/
it shows my code but on browser when I run http://myapp.com:8000/ it shows "No input file specified."
By default a webserver usually looks for index.html then index.php, neither of these files are in your /home/vagrant/Code folder which is why you're getting the "No input file specified" error.
On your sites section, you should map the domain to your public folder of Laravel. So in this case it should likely be /home/vagrant/Code/public
You mapped codebase to Code, and you mapped myapp.com to Code.
If you currently have an app in codebase/app1/index.php, then this wouldn't work because myapp.com is looking for index.php inside Code.
Thus, you need to access either: myapp.com:8000/app1 OR you need to remap sites like so (and do this for every site/app folder inside codebase):
sites:
- map: myapp.com
to: /home/vagrant/Code/app1
Note that you need to replace app1 with whatever you called your app's folder in XAMPP
Related
I'm trying to install Homestead on a Mac using VirtualBox and when I edit the homstead.yaml file to change the location of my local shared folder the change never registers, as I always get the error
The host path of the shared folder is missing: ~/Code
when I vagrant up.
When I performed bash init.sh I was asked to overwrite homestead.yaml, after.sh, and aliases. I've been having this problem for a while now and have tried many different things but nothing seems to work. I new with Laravel and would appreciate some help. Thanks!
In your Homested.yaml file but make sure you have folder in your C:\Code
folders:
- map: C:/Code
to: /home/vagrant/Code
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
I'm having problem to understand how to run my website using vagrant and Laravel Homestead environment.
I added laravel/homestead box without any problems. Then I ran vagrant init laravel/homestead and it worked too.
I managed to create Homestead.yaml and here's what it contains:
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/www
to: /home/vagrant/code
sites:
- map: project.dev
to: /home/vagrant/code/project
databases:
- homestead
variables:
- key: APP_ENV
value: local
vagrant up runs correctly, but I don't know how to access my website. I added 192.168.10.10 project.dev to my /etc/hosts.
I want to keep my project at ~/www/project. First thing that I didn't understand from the docs is, what is the folder at sites / map / to setting supposed to be? My local folder or a folder in the virtual environment?
The next thing I don't understand is why when I do vagrant ssh and then ls, I don't see any files, even though there's index.php at my ~/www/project. I thought they are going to be synchronized automatically.
When I go to project.dev in the browser, it timeouts. I tried project.dev:8000 as well and 192.168.10.10, but nothing works.
Please help me.
You are forgetting the folders parameter, also your indentation should be with spaces and not with tabs, thats the way yaml works, everything else seems to be fine but try to make it with something similar to this one
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/www/project
to: /home/vagrant/code
sites:
- map: project.dev
to: /home/vagrant/code/project/public
databases:
- homestead
variables:
- key: APP_ENV
value: local
you're missing the folder share settings in you're homestead.yaml file.
Try adding
folders:
- map: ~/www/project
to: /home/vagrant/code
Look at the docs here
http://laravel.com/docs/5.1/homestead#configuring-homestead under Configuring Shared Folders
I think this is the common issue that someone new to Laravel Homestead is facing.
Laravel Homestead basically provides an image that gets a VM ready for Laravel development. The yaml config on "sites" is basically use to configure Nginx - it does not install a Laravel project on the path specified.
So for a new homestead VM, you just have to ssh into your Homestead VM, and type and run this:
composer global require "laravel/installer=~1.1"
Once done, on you /home/vagrant/code folder (in the VM, not your host), type and run this:
laravel new project
Where the "project" is the name given to your new project. Since your yaml is already configured to "project", the above command will work fine. Obviously, this is clearly not the only way to get Laravel as you can use composer create-project to install Laravel directly.
Once done, you should be able to visit http://project.dev on your host's browser, if your host file is configured with this added entry:
192.168.10.10<tab>project.dev
Alternatively, you can configure your host file to be
127.0.0.1<tab>project.dev
Which you can then view on your host's browser via http://project.dev:8000
Hope the above explains clear enough. Enjoy!
I think I finally got homestead installed on my laptop! Now, I am trying to view my laravel project in the browser.
When I open "dev.app" in the browser I get a message that say "No input file specified." which I think means that my homestead is working but the laravel project is not there/setup.
I have created a folder called Projects on my local laptop (i.e. ~/Projects). Then from inside of it i executed this command
laravel new dev
But I still get the same error message in the browser i.e. "No input file specified." I have also tried to open this link "dev.app"/dev" but I still get the same message.
What I am doing wrong?
Here is the content of my Homestead.yaml file
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Projects
to: /home/vagrant/Code
sites:
- map: dev.app
to: /home/vagrant/Code/Laravel/public
databases:
- homestead
variables:
- key: APP_ENV
value: local
Additional, when I execute the following 2 commands in order
cd ~/Projects
ls
I see the following directories dev homestead
What should I do to see my project when I go to dev.app ? Do I need to do anything from my Ubuntu VM or I should be able to edit the files directly in located on ~\Projects\dev" from my laptop?
Add an entry in /etc/hosts on your local machine
192.168.10.10 dev.app
Correct the path to the public folder in the sites section of your Homestead.yaml
sites:
- map: dev.app
to: /home/vagrant/Code/dev/public
I'd like to use laravel homestead for my development machine and installed virtualbox and vagrant successfully, but when I run vagrant up I get this error:
Bringing machine 'default' up with 'virtualbox' provider...
There are errors in the configuration of this machine. Please fix
the following errors and try again:
vm:
* The host path of the shared folder is missing: ~/Code
The Homestead.yaml file looks like this:
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Code
to: /home/vagrant/Code
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
hhvm: true
databases:
- homestead
variables:
- key: APP_ENV
value: local
These are the default settings, but they don't really work for my machine - I don't even have /home/vagrant folder nor do I have ~/Code anywhere where I can see. I'm using ubuntu 12.04 - can you please point me to how I should configure my settings because by the official documentation I'm kind of lost.
Inside the homestead directory, you have to run the command bash init.sh.
This will generate the Homestead.yaml file (and after.sh and aliases) inside your home directory (~).
If you are changing Homestead.yaml again, you have to re-run bash init.sh again. It will ask for overwrite, say yes.
(and as mentioned in other answers, be sure that the directory for folders: - map: exists)
In your Ubuntu machine you have to let Homestead know where your actual code is located. Example:
If you code is located in a seperate partition called WORKSPACE you need to type the following:
- map: /Volumes/WORKSPACE/YourProject
to: /home/vagrant/Code
In Windows case I used this:
- map: e:/GIT/PHP/mathmaps/Code
to: /home/vagrant/Code
P.S. GIT is my workspace folder
running bash init.sh a second time will prompt to overwrite the initial setup, this will also output the directory path you require to edit the correct Homestead.yaml file.
The map: attribute has to be set to the location to where you want to keep your code. For example, I will be saving my code in a folder called code within the Homestead folder therefore, map is:
folders:
- map: ~/Development/Homestead/Code
to: /home/vagrant/Code
Where 'Development' is simply a folder in my home directory where I keep all my code
I installed Laravel Homestead on my Mac, where my Laravel site lives locally at Users/me/Homestead/Site/Laravel. I've been using this to play around and do some real basic introductory testing.
Here is my Homestead.yaml:
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
authorize: /Users/me/.ssh/id_rsa.pub
keys:
- /Users/me/.ssh/id_rsa
folders:
- map: /Users/me/Homestead/Site
to: /home/vagrant/Site
sites:
- map: homestead.dev
to: /home/vagrant/Site/Laravel/public
variables:
- key: APP_ENV
value: local
First of all, homestead.dev doesn't work. I can access the site at localhost:8000. But I'd like to get the vanity URL working locally... otherwise what's the point of having it in there...
Secondly, I'd like to change the Site folder's name to www, just for kicks. Can I do that and then just change its paths in my Homestead.yaml and everything will just fall into place? Can I do this while vagrant is up or should I make Homestead.yaml edits with it halted or suspended..?
Last but not least I want to add a second site, so within www (or Site currently), another folder, containing another Laravel project/site. In that case do I just add a second mapping under sites in Homestead.yaml? Again, does this edit have to be done with the VM halted?
How do I go about doing all this?
Thanks in advance.