On Win10, how does one use Vagrant to install Homestead ?, Win10vagrant
I have recently studied Laravel and want to use the Homestead integrated environment recommended by Laravel. However, according to the online tutorial, the installation was not good for two days! I finally learned how to do it today, so I am going to share it with you.
First install the software mentioned above. It is best to use the default directory, especially VirtualBox, when installing Git, VirtualBox, and Vagrant. Otherwise, Vagrant cannot find VirtualBox.
You need to restart Vagrant during installation, so you can stay in the final installation.
Install composer.exe to configure the PHP environment first, so you must specify the php.exe file during installation. These are all very simple, and I will not be able.
Follow these steps to install Homestead:
Run "Git Bash" as an administrator to verify that Vagrant has the input: vagrant-v
Install Homestead. Enter vagrant box add laravel/homestead.
There is an option to install VirtualBox, so select 2.
Then start downloading. The download speed is very slow... Don't wait. Press Ctrl + c to cancel. That's right. There is a. box file. copy it and use the download tool to download it. I downloaded the latest version 1.0.1, which is about 1 GB in size.
After the download, you can change the file name to virtualbox. box. I will move it to the C-drive root directory to facilitate the input of the address.
Then enter: vagrant box add laravel/homestead "C: \ virtualbox. box"
It is best to enclose the quotation marks or use a backslash. Enter: vagrant box add laravel/homestead C:/virtualbox. box
View the installed box. Enter vagrant box list.
Return to the user's Home directory and copy a file from git. Failed to delete the Homestead folder and try again.
After the operation is successful, it will be placed under the "C: \ Users \ <username> \" directory. Here I am: C: \ Users \ huang
Input:
Cd ~
Git clone https://github.com/laravel/homestead.git Homestead
Initialize the homestead configuration file. The. homestead folder is generated in the user's Home directory.
Input:
Cd ~ /Homestead
Bash init. sh
Create an SSH key and enter ssh-keygen-t rsa-C "you @ homestead"
Press enter after entering all
In this step, other tutorials are basically called editing the homestead. yaml file in the. Homestead folder under the user's Home directory. If you are not busy, try the running effect first. The box file of laravel/homestead just installed was not found, because it was not initialized.
Input as follows:
Cd ~ /Homestead
Vagrant up
Initialize the box file, but first you have to change the name of Vagrantfile In the Homestead folder under the user's Home directory to Vagrantfile. bak for backup.
Enter the following parameters in sequence:
Cd ~ /Homestead
Vagrant init
The above step will generate a new Vagrantfile file. After executing: vagrant up, it still says no base is found. That's because the name is incorrect. Use the editor to open the Vagrantfile file, change the base to laravel/homestead, and then execute.
Input:
Cd ~ /Homestead
Vagrant up
I don't know why my virtual machine has been stuck at the logon location. Maybe it is because the virtual machine cannot run any more. Haha! I switched to the local machine to continue.
It is started now, but it is useless. No code is copied or Nginx is enabled. Next, rename the Vagrantfile (or delete it) and change Vagrantfile. bak back. But it cannot run now.
The most important part is to edit the homestead. yaml file under. Homestead in the Home directory. The reason is that the "homestead-7" machine is enabled by default, but we have no name, so it is called "default ".
Add two lines under provider: "virtualbox:
Name: "default"
Box: "laravel/homestead" (optional)
Configure the Project address, as shown in the figure above. make it clear. The project path on windows needs to exist, and homestead is automatically created and synchronized.
Install laravel in composer. Input: composer global require "laravel/installer"
Go to your project path and create a project. Enter laravel new <Project Name>
If you are not familiar with creating a laravel project, read the Laravel documentation.
Reload Homestead.
Input:
Cd ~ /Homestead
Vagrant reload -- provision
Now your project is synchronized with Homestead. Enter 192.168.10.10 in the browser to see the welcome page of Laravel. Modify the host file of windows to use the homestead. app domain name.
Add a row: 192.168.10.10 homestead. app
Finally, you can use ssh to log on to homestead. We can see that this is based on ubuntu.
Input:
Cd ~ /Homestead
Vagrant ssh
Enter: exit to exit ssh. Input: sudo poweroff to disable homestead (ubuntu ).
You can use vagrant up In the Homestead directory to enable it next time.
This is the end of the article. I will not talk about how to install it.