I am trying to install Laravel 5.2 and I got to the point where I am configuring homestead.yaml file. I understand that /home/vagrant/Code/Laravel/public is where my project files should be located:
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
I am on Windows 7 and I can't find where this /home folder is. Does anyone know where it is? Or is my laravel project located in another folder?
This folder is inside virtual machine. You need to map real folder on your PC (like C:\Laravel\public) to VM folder /home/vagrant/Code/Laravel/public.
You can use your VM with SSH client, like WinSCP and you'll see all folders there:
host: 127.0.0.1
login: vagrant
password: vagrant
That configuration option is where you provide virtual hosts for various applications that you'll be using homestead for.
By default, when you configure homestead you specify a directory that you want mounted onto the virtual machine, for me it's D:\Users\me\Projects\PHP. Homestead mounts this folder to /home/vagrant/Code.
That path is for the virtual machine and only the last part after /Code has any connection with your actual Windows machine.
It's by default located realtive to your home directory on windows, i.e.
C:\Users\[user]\Code
Note: you might want to create the Code folder first inside C:\Users\[user]
Related
I have MAMP installed on my Mac with MacOS HighSierra 10.13.4.
I have ran composer create-project roots/bedrockin my /Applications/MAMP/htdocsfolder.
I have started up my servers via the MAMP UI. When I surf to http://localhost:8888/MAMPI get the MAMP startpage so everything seems to be working fine.
When I go to http://localhost:8888/bedrock I get a list of my files and dirs in my bedrock folder:
Index of /bedrock
Parent Directory
.env
.env.example
.gitignore
CHANGELOG.md
...
This is what my .env file looks like:
DB_NAME=adatabase
DB_USER=auser
DB_PASSWORD=apassword
# Optional variables
# DB_HOST=localhost
# DB_PREFIX=wp_
WP_ENV=development
WP_HOME=http://localhost:8888/bedrock
WP_SITEURL=${WP_HOME}/wp
I am wondering what I am doing wrong since I don't see the WordPress installation page.
It looks like apache, by dint of MAMP's default config, isn't serving from the correct directory for a bedrock project.
According to the bedrock docs, you should:
Set your site vhost document root to /path/to/site/web/ (/path/to/site/current/web/ if using deploys)
So, you'll need to modify your MAMP config to serve this project not from /Applications/MAMP/htdocs/bedrock, but from /Applications/MAMP/htdocs/bedrock/web.
You will need to click Set Web & MySQL ports to 80 & 3306 via MAMP > Preferences > Ports.
Then http://localhost/bedrock
Please let me know if this works :)
I am seeing 403 forbidden when trying to visit the url after setting up a homestead VM. I think my paths must be wrong but I cant figure out where..
I am on a Mac.
I have a file on my local machine which contains a Laravel project
/Users/<my-name>/Sites/laravel_projects/public/my-app
My homestead.yaml looks like
folders:
- map: /Users/<my-name>/Sites/laravel_projects
to: /home/vagrant/Code
sites:
- map: homestead.app
to: /home/vagrant/Code/public/my-app
Running vagrant global-status I see.
id name provider state directory
5d79357 default virtual box running /Users/warrenday/.composer/vendor/laravel/homestead
I have tried running homestead provision to restart the VM but I'm not sure if this is needed.
Assuming you're using standard Laravel file structure, you're doing this the wrong way.
When installing Laravel, your public folder will look like this: my-app/public not public/my-app.
sites:
- map: homestead.app
to: /home/vagrant/Code/my-app/public
And not sure if you missed something or its a MAC thing (windows guy here), but /Users//Sites/laravel_projects doesn't seem right (two //)
And unless you've already done this, you need to make sure that in your hosts file you add 192.168.10.10 homestead.app (or your equivalent vagrant ip)
I have been using XAMPP for quite a time, and after discovering Laravel and finding out, that I quite like it, I also wanted to use Homestead. The problem I'm having is, that I can't seem to be able to run multiple sites.
I have tried various things, but the main problem currently is, that one project works, while all the others are getting a connection timeout, when trying to access their webpage.
These are the steps I've taken to use Homestead
Installing VirtualBox
Installing Vagrant
Adding homestead with vagrant box add laravel/homestead
Clonging the repository git clone https://github.com/laravel/homestead.git Homestead
Create Homestead.yaml file in the Homestead directory with the bash init.sh script
Create a new project laravel new projectA
Require homestead composer require laravel/homestead
Generate Vagrantfile php vendor/bin/homestead make
Modify the Homestead.yaml to have an IP that ends with 10
Create another project laravel new projectB
Require homestead composer require laravel/homestead
Generate Vagrantfile php vendor/bin/homestead make
Modify the Homestead.yaml to have an IP that ends with 11
Adding those two sites to the hosts file sudo nano /etc/hosts => xxx.xx.xx.10 projecta.app & xxx.xx.xx.11 projectb.app
Starting vagrant from one of the two directories vagrant up
Now, I'm having the problem, that only one of the projects is reachable. It's always the one from where I called vagrant up. So if I call vagrant up from Project A I can access http://projecta.app and http://projectb.app times out. The same the other way around, sadly.
This is my vagrant global-status
id name provider state directory
------------------------------------------------------------------------
fc6fadb default virtualbox running /Users/mknb/work/projectA
I thought I would just do another vagrant up from the projectB directory but that doesn't work of course.
I don't want to use the global Homestead, because Laravel said, that it is possible to have a per project installation, so how do I achieve it? Do you need more information?
I didn't modify the Homestead.yaml except of the IP and the domainname homestead.app => projecta.app
It seems like a global installation is fairly easy with Homestead, since I would just have to add more sites to the Homestead.yaml, but as I said I'd like to have a per project installation. Can anybody help?
Starting vagrant from the Homestead directory doesn't work of course.
By using Homestead in your way, you create a virtual machine for each projects. Therefore, the VirtualBox cannot forward the HTTP request from your host machine for all of virtual machine. You can only run one machine (so, one project) each time.
To run multiple projects with Homestead, you can do as follow:
Clone Homestead git clone https://github.com/laravel/homestead.git Homestead
Inside the Homestead folder, run bash init.sh
Edit the folders property of ~/.homestead/Homestead.yaml to share your code of both projects with VM:
folders:
- map: ~/pj1
to: /path/to/project1
- map: ~/pj2
to: /path/to/project2
Edit the sites property of ~/.homestead/Homestead.yaml to make Nginx enable the domain of both site:
sites:
- map: project1.local
to: /home/vagrant/pj1/public
- map: project2.local
to: /home/vagrant/pj2/public
Edit your hosts file to forward these domain fo localhost
127.0.0.1 project1.local
127.0.0.1 project2.local
Run vagrant up at the folder that you cloned the Homestead code inside it (which contains the init.sh file).
Now, you can run as many project as you want with just one Homestead virtual machine.
There are some important steps missing in the accepted answer although it helped me lot. I have added those necessary steps. Thanks #Hieu Le for answer.
I assume you have correctly installed your fist site as by the instructions of Laravel docs. Now you have another laravel site which you want to shift on vagrant. Follow the following steps.
cd into the directory of new Laravel project which you want to add. I assume you have all laravel files in it and its working using MAMP or any non-vagrant solution.
run vagrant init laravel/homestead. This command will add the necessary VagrantFile in this new project.
open the directory of your first original project file and open its
Homestead.yaml file in editor.
Now follow the steps defined by #Hieu Le in accepted answer to
modify .yaml file
folders:
- map: ~/pj1
to: /path/to/project1
- map: ~/pj2
to: /path/to/project2
sites:
- map: project1.local
to: /home/vagrant/pj1/public
- map: project2.local
to: /home/vagrant/pj2/public
Edit your hosts file to forward these domain fo localhost
127.0.0.1 project1.local
127.0.0.1 project2.local
On terminal cd into your first original original project
directory.
Run command vagrant reload --provision. This will reload the
vagrant machine so that the changes which we made in .yaml file come in effect. You database of original project will remain intact.
Run vagrant ssh
Run ls and make sure you can see the folder of your new project. If its there
you have configured your new site correctly.
Hit the url of new site with addition of http:// and your are
DONE.
Like how here says, you can install Homestead directly into your project, require it using this composer require laravel/homestead --dev at root directory of each project you have. Now by make command you can generate Vagrantfile and Homestead.yaml file into your project's root directory.
Mac/Linux:
php vendor/bin/homestead make
Windows:
vendor\bin\homestead make
On each project root you will have a Homestead.yaml file to edit:
Project-A
ip: "192.168.10.10"
...
folders:
- map: "~/Code/projecta"
to: "/home/vagrant/projecta"
sites:
- map: project.a
to: "/home/vagrant/projecta/public"
Project-B
ip: "192.168.10.10"
...
folders:
- map: "~/Code/projectb"
to: "/home/vagrant/projectb"
sites:
- map: project.b
to: "/home/vagrant/projectb/public"
Add this to /etc/hosts:
192.168.10.10 project.a
192.168.10.10 project.b
Then you have to cd to each project's root and vagrant up.
Now if you vagrant ssh from each project, you will have that project in your VM environment.
there is a short cut command to proxy the sites you want to add..
without having to messed up your Homestead.yaml file and provision your vagrant box all over again...
This applies to BOTH GLOBAL AND PER PROJECT INSTALLATION
Just Make sure if you are adding another project...
You add it the (whole project) on your Shared Folder
Declared in your Homestead.yaml
Assuming your shared folder is
C:/Users/MYACCOUNT/Codes
Add another project in that Folder
laravel new homestead.app
Then
Assuming your are ssh in your Homestead
Type
a.) if your using nginx
serve homestead.app /home/Vagrant/Code/homestead/public
b.) if your using hhvm
serve-hhvm homestead.app /home/Vagrant/Code/homestead/public
Just change your domain name and path to public folder of your project
Then Edit your etc/hosts file as Administrator
What ever ip address you define in your Homestead.yaml
usually the default is 192.168.10.10
Use it instead of 127.0.0.1
Why? because if you use 127.0.0.1 your url will look like
homestead.app:8000
If you Use the IP address in the Homestead.yaml
192.168.10.10 homestead.app
you can access your site without port 8000
and just use homestead.app
This Solution is Much Better than Provision... And is Faster...
This is what i Do
Step 1: First you just map your other project and database in the homestead.yaml file enter image description here.
Step 2: Create the database you mentioned in the existing workbench connection enter image description here.
Step 3: Mention that database in your project .env file. enter image description here
Step 4: Add another path in your drivers/etc/hosts file and run homestead reload --provision. Your problem is solved. :)enter image description here.
I believe I have everything set up exactly as it should be but consistently receive the following message when attempting to view my app in the browser.
Can anyone tell me where I may be going wrong? I don't have anything set up in Oracle VM Virtualbox manager. Could this be it?
My hosts file has
127.0.0.1 homestead.app
My browser is returning
My project folder is set up as follows:
In my homestead.yaml, I 'think' my paths are correct
SSH into vagrant shows all files in projects/bookings folder
I am not sure, but I don't see bookings folder inside Code folder, my yaml file looks:
folders:
- map: C:\wamp\www\_homestead
to: /home/vagrant/Code
sites:
- map: xilo_black.app
to: /home/vagrant/Code/xilo_black/public
and my local folder structure is
...www_homestead (here are my all files connected to vagrant and homestead and .vagrant folder)
...www_homestead\xilo_black (laravel files)
In code folder, there should be folders with apps
Code\bookings\public
Code\other_app\public
OK, I had to follow instructions on this link to ssh into vagrant machine and create a Laravel project there.
My sites in homestead.yaml then mapped to
sites:
- map: homestead.app
to: /home/vagrant/Code/bookings/public
http://laravel.io/forum/06-04-2014-no-input-file-specified-using-homestead
you need to change the ip in the host file to the same ip you have in the homestead file
192.168.10.10 homestead.app
I new with virtual box and vagrant , Now I using Homestead image and every thing is run well
but when i create my project named laravel on virtual machine it supposed that i see this new folder named laravel on my machine but i didn't get any thing on my machine.
when i type url http://homestead.app:8000/ i get This webpage is not available
The synchronization is not working and
NOTE: - I'm using ubuntu 14.04
This is my homestead.yaml
ip: "192.168.10.10"
memory: 2048
cpus: 1
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: /var/projects/
to: /home/vagrant/projects/
sites:
- map: homestead.app
to: /home/vagrant/projects/laravel/public
variables:
- key: APP_ENV
value: local
thanks advance
...when i create my project named laravel on virtual machine it
supposed that i see this new folder named laravel on my machine...
I've run into this before. The root laravel project folder needs to be created on your real machine first. Then setup the site folder mapping above as you have done.
Then afterwards any further changes inside the virtual machine will replicate/sync both ways.