Laravel-1.2 Installation-C) Create Vagrant Box

Source: Internet
Author: User
Tags curl mkdir

Original address: Creating a vagrant Box problem

You need to create a sandbox in the vagrant.
Even though you have VirtualBox and vagrant installed, you can't run any work solutions in the sandbox.

Build a vagrant Box
This example will create an Ubuntu 14.04 64bit vanilla box, vanilla means that no additional tools are installed. It's like a brand-new installation of the finished machine. Step 1-Create a sandbox directory

In the terminal, create the directory structure

$ mkdir vagrant
$ mkdir vagrant/laravel
$ mkdir vagrant/laravel/projects
Step 2-Create Vagrantfile file

Switch to the newly created Vagrant/laravel directory and create a file named Vagrantfile that writes in this file

Vagrantfile_api_version = "2"

vagrant.configure (vagrantfile_api_version) do |config|
  Config.vm.box = "Precise64"
  config.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/trusty/current/ Trusty-server-cloudimg-amd64-vagrant-disk1.box "
  config.vm.network:p rivate_network, IP:" 192.168.100.100 " End

[To]: because the website visit speed is very slow, here can go to http://www.vagrantbox.es/to download the mirror that you need first and then the HTTP that line replaces directly to your local mirror path is more convenient and quick, my box directory is vagrant/box/ Trusty-server-cloudimg-amd64-vagrant-disk1.box, the path to the configuration is.. /box/trusty-server-cloudimg-amd64-vagrant-disk1.box Step 3-Create a virtual machine

This will be based on vagrantfile content downloads, creating and configuring virtual machines

$ cd vagrant/laravel
$ vagrant up

This will last a while, especially when you first run the installation precise64.

[To]:
Step 4-Configure the operating environment

Next we'll connect to the virtual machine and make some minor changes.

$ cd vagrant/laravel
$ vagrant SSH

: Because no SSH client will prompt this error

Here will Cygwin, MinGW, Git's Ssh.exe file directory into the environment variables and then rerun the OK

After you connect successfully, your cue will become vagrant@precise64-vanilla, which means you have successfully logged into the virtual machine.

vagrant@precise64-vanilla:~$ echo "Export ps1= ' laravel:\w\$ '" >> bashrc
vagrant@precise64-vanilla:~$ ln-s /vagrant/projects
vagrant@precise64-vanilla:~$ cat << EOF | sudo tee-a/etc/motd.tail

*****************

Welcome to Precise64-vanilla vagrant Box for

laravel development

****************
EOF
vagrant@precise64-vanilla:~$ exit
Step 5-Install the basic project

Now when you connect you will receive the new welcome message we created in our final step, now the prompt will be ' laravel ' instead of ' Vagrant@precise64-vanilla '.

$ cd vagrant/laravel
$ vagrant ssh
laravel:~$ sudo apt-get update
laravel:~$ sudo apt-get install-y Software-properties build-essential
laravel:~$ sudo add-apt-repository-y ppa:ondrej/php5
laravel:~$ sudo Apt-get update
laravel:~$ sudo apt-get install git-core subversion Curl php5-cli php5-curl \
laravel:~$ exit
discussion

The following are detailed steps for each step

Step 1
Create a subdirectory named vagrant, all vagrant files are saved in this folder, Laravel directory to save the virtual machine we created, if you set another virtual machine, under Vagrant Create another directory on the OK

Step 2
The Vagrantfile file specifies the name of the virtual machine (precise64) and tells how to find the URL, the first time the virtual machine is installed, vagrant will download the mirror, but the installation will be much faster later

Config.vm.network Line code specifies that this virtual machine has a 192.168.100.100 IP, and you can use any IP address that doesn't conflict with your intranet, just keep 192.168.*.* this format ok

When the virtual machine is running, you can use the browser to access 192.168.100.100来 View the pages on the virtual machine [the premise is that you installed the Web server]

Step 3
The Vagrant up command starts the virtual machine and launches it. This step may be performed for some time. Especially when you run Precise64 for the first time you need to download the operating system. Once the machine is configured, it takes only two seconds to start.

Step 4
echo "Export PS1 ..." This line will be created the next time you log on to the virtual machine, which will use vagrant:~$ instead of vagrant@precise64-vanilla:~$. If you use multiple vagrant virtual, you need to identify which virtual machine you are running by using this identifier.

Ln-s/vagrant/projects Creates a directory soft connection in the root directory of the project to the first step (?). All new Laravel projects will be created here and can be edited on the main operating system. Vagrant and hosts to share this directory. If you edit ~/vagrant/laravel/projects/test.txt from the host, you can also vagrant the ~/projects/test.txt to see the file.

Step 5
This step installs the underlying system components. He contains Git, subversion, and the latest version of PHP

These setup steps are well-known rules. Vagrant offers a number of ways to install a virtual machine. View provisioning vagrant with a Shell Script

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.