Home IT Linux Windows Database Network Programming Server Mobile  
  Home \ Server \ Use Vagrant up a local development environment tutorials     - View processes and threads under Linux (Linux)

- Linux file permissions to modify the command: chmod (Linux)

- Enterprise Hadoop cluster architecture - NFS installation (Server)

- Minimum period string problem (Programming)

- Source code is installed MySQL 5.6.28 (Database)

- MySQL database under Linux to achieve automatic backup scheduled backup day (Database)

- The Concept and Semantics of Java Memory Model (Programming)

- shell script: the number of characters in the text to print no more than 6 words (Programming)

- How to extend / remove swap partitions (Linux)

- Linux performance monitoring (Linux)

- Java implementation of stacks and queues (Programming)

- How to use the internal network IP forwarding to connect to the Internet on Linux (Linux)

- Implicit conversion from Java type conversion compare MySQL and Oracle (Database)

- Ubuntu disable graphics card (Linux)

- Linux Shell Scripting multithreading (Programming)

- Nonstandard IMP-00010 error processing one case (Database)

- Usage of sudo (Linux)

- Linux crontab use (Linux)

- Oracle 11g tracking and monitoring system-level triggers to drop misuse (Database)

- Spring Boot + Nginx + Tomcat + SSL configuration notes (Server)

  Use Vagrant up a local development environment tutorials
  Add Date : 2017-08-31      
  You set up a local development environment for php could prepare you in the local development environment above do a project, when you migrate it to a real server, you found some problems. This is most likely because there is between your local development environment and server production environment distinction. Slowly, you want to try something node, because it is a good relationship with JavaScript. Or ruby again generated interest, just because she has a good name. Try these you will need to install some software to configure their operating environment, you find more and more, the management of these environments may be a problem.

Vagrant allows you to create a project for each virtual machine, you can select the operating system of the virtual machine is running, the need to configure the environment, such as installing Web servers, database management systems. Catalog items can be placed on your computer, it will sync with a directory on the virtual machine. Between your computer and the virtual machines can access each other, so, as usual, you can use your favorite editor to develop Web applications, and then use the virtual machine environment configured to run your project. Use Vagrant, you can use to configure a virtual machine on your local computer as a production environment with the Web application environment, the same operating system, the same software, the same configuration. You can also share your development environment and other members of the team,


Download and install the following two things:

VirtualBox is a free open source virtual machine software, cross-platform, Windows, OS X can be used. Vagrant is also cross-platform. This article presentation is done in the OS X operating system below.


box is a virtual machine image can be downloaded to the Vagrant Cloud Inside, you can choose what you want the operating system, and here I use the CentOS 6.5, because my site production environment, but also intends to use CentOS 6.5 operating system . Here I use it is:

chef / centos-6.5
Back to the command-line tool, go to the box downloaded to the local computer, and add to the vagrant inside:

vagrant box add chef / centos-6.5

==> Box: Loading metadata for box 'chef / centos-6.5'
    box: URL: vagrantcloud.com/chef/centos-6.5
This box can work with multiple providers! The providers that it
can work with are listed below. Please review the list and choose
the provider you will be working with.

1) virtualbox
2) vmware_desktop
Because we are using VirtualBox, therefore, there should choose the first option, enter the number 1, and then press Enter. Such vagrant downloaded from our designated box on Vagrant Cloud. Because the image contains the operating system, it is generally relatively large, several hundred MB to several G has.

After completion, enter the following command to view the box can be used:

vagrant box list

chef / centos-6.5 (virtualbox, 1.0.0)
Now, you can use the CentOS-6.5 version of the operating system to run we want to develop a Web application.


Open a command-line tool, OS X can use the system comes on top of a terminal tool, Windows users can use command prompt tools. Then create a directory for the project, it can be placed anywhere. I'm going on the currently logged on user's desktop, create a directory called linuxidc.net:

cd ~ / desktop
mkdir linuxidc.net
Into the directory created for this project:

cd linuxidc.net
Then Run the initialization of the project:

vagrant init chef / centos-6.5
Prior to the above command is to use our download and add the chef / centos-6.5 Click the box to initialize the project, that is, our project will be run in a virtual machine centos 6.5 this version of the operating system on.

Implementation of the above command line, the directory of the project which will generate a file called Vagrantfile, this file tells the kind of vagrant how to run the virtual machine.

Network Configuration

If you want to be able to communicate with each other on your computer with a virtual machine, such as your virtual machine installed on a Web server, you're going to be able to on the local computer, or other devices on the same network can access this virtual machine on the project. This need to do some configuration, there are three ways, port forwarding (Forwarded Ports), private networks (Private Network), public network (Public Network).

Next, we went to a public network configuration, that is, you can access to a virtual machine on your computer through an internal ip address of other devices within the same network, you can also have access to this virtual machine.

First open project directory below Vagrantfile file. Find this line of code:

# Config.vm.network "public_network"
Remove the # in front of it:

config.vm.network "public_network"
save document.

start up

After configuring the network, it is possible to start the virtual machine, and to determine the current directory is the directory where the project, and then execute:

vagrant up

Bringing machine 'default' up with 'virtualbox' provider ...
==> Default: Importing base box 'chef / centos-6.5' ...
==> Default: Matching MAC address for NAT networking ...
==> Default: Checking if box 'chef / centos-6.5' is up to date ...
==> Default: Setting the name of the VM: linuxidcnet_default_1404827171486_40050
==> Default: Fixed port collision for 22 => 2222. Now on port 2200.
==> Default: Clearing any previously set network interfaces ...
==> Default: Available bridged network interfaces:
1) en1: Wi-Fi (AirPort)
2) en0: Ethernet
3) en4: Thunderbolt 1
4) en3: Thunderbolt 2
5) p2p0
6) bridge0
    default: What interface should the network bridge to?
After the configured network, the first time you start, there will be such a prompt above, let us choose bridge mode, choose which depends on your network environment. For example, my computer is in a small local area network, the Internet through a wireless router, so here, I chose the first option: en1: Wi-Fi (Airport). Enter the number 1, and then press Enter.

==> Default: Preparing network interfaces based on configuration ...
    default: Adapter 1: nat
    default: Adapter 2: bridged
==> Default: Forwarding ports ...
    default: 22 => 2200 (adapter 1)
==> Default: Booting VM ...
==> Default: Waiting for machine to boot This may take a few minutes ....
    default: SSH address:
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning:. Connection timeout Retrying ...
    default: Warning:. Remote connection disconnect Retrying ...
==> Default: Machine booted and ready!
==> Default: Checking for guest additions in VM ...
==> Default: Configuring and enabling network interfaces ...
==> Default: Mounting shared folders ...
    default: / vagrant => /Users/xiaoxue/Desktop/linuxidc.net

After the start, we can ssh to the virtual machine. Use the command:

vagrant ssh
This can operate as a normal Linux server, to install the software, configuration, and so on.

Note that the directory on your computer projects virtual machine inside / vagrant This directory is synchronized.

Install nginx

Next, we installed on the virtual machine at the Web server nginx as a demonstration. On CentOS a complete system configuration can run php environment.

wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
Then execute:

sudo rpm -ivh nginx-release-centos-6-0.el6.ngx.noarch.rpm
Then install nginx with yum:

sudo yum install nginx
After installation is complete, you can start nginx service:

sudo service nginx start
After the start of the service nginx virtual machine on our computers in the same network or other device, you can access to this virtual machine to provide Web services. But first we need to know which virtual machine network, including IP addresses, execute the command:


eth0 Link encap: Ethernet HWaddr 08: 00: 27: CE: 08: 3D
          inet addr: Bcast: Mask:
          inet6 addr: fe80 :: a00: 27ff: fece: 83d / 64 Scope: Link
          RX packets: 596 errors: 0 dropped: 0 overruns: 0 frame: 0
          TX packets: 397 errors: 0 dropped: 0 overruns: 0 carrier: 0
          collisions: 0 txqueuelen: 1000
          RX bytes: 61284 (59.8 KiB) TX bytes: 50362 (49.1 KiB)

eth1 Link encap: Ethernet HWaddr 08: 00: 27: C4: AB: A1
          inet addr: Bcast: Mask:
          inet6 addr: fe80 :: a00: 27ff: fec4: aba1 / 64 Scope: Link
          RX packets: 2 errors: 0 dropped: 0 overruns: 0 frame: 0
          TX packets: 11 errors: 0 dropped: 0 overruns: 0 carrier: 0
          collisions: 0 txqueuelen: 1000
          RX bytes: 1180 (1.1 KiB) TX bytes: 1578 (1.5 KiB)

lo Link encap: Local Loopback
          inet addr: Mask:
          inet6 addr: :: 1/128 Scope: Host
          UP LOOPBACK RUNNING MTU: 16436 Metric: 1
          RX packets: 0 errors: 0 dropped: 0 overruns: 0 frame: 0
          TX packets: 0 errors: 0 dropped: 0 overruns: 0 carrier: 0
          collisions: 0 txqueuelen: 0
          RX bytes: 0 (0.0 b) TX bytes: 0 (0.0 b)

My computer in the LAN has an internal IP address, the address is 192.168.1. *, In the other devices inside the network, such as iPhone, iPad or other computer, their internal IP addresses are this form. So, I can tell, eth1 inside, which should be the virtual machine, including the network's IP address.

On your computer, open a browser and enter, you should be able to access the Web services provided by the virtual machine.


Turn off the virtual machine:

vagrant halt
Restart the virtual machine:

vagrant reload
Destruction of a virtual machine:

vagrant destroy
Detailed instructions, you can view vagrant official documents.


Today, together with everyone in the group qq, we test it under Windows to install the configuration vagrant. I also installed Windows on a virtual machine to do the test. Most people have successfully configured, and summarize the following common problems.

In addition, when a vagrant box, and pay attention to the version of the system. If your operating system is 32-bit, then you must also download the box is 32, and you want the search box on VagrantCloud, then select the appropriate version. For example, this article I recommend installing the chef / centos-6.5 this box, it is a 64-bit system. If you need a 32-bit system, you can try vagrant init rafacas / centos65-i386-plain.

Using vagrant up, after the start, use ssh to connect to a virtual machine, Windows users can use putty, fill in the host, port number is 2222, the user login name is the vagrant, the password is vagrant.

With vagrant package packing box after running, you can add the box, with vagrant box add command. Next time init project, you can use this box a. At boot time, you may encounter problems, my problems are caused by the card, the solution is to remove /etc/udev/rules.d/70-persistent-net.rules.


Today found nginx server can not synchronize static files locally edited, the solution is to edit the nginx configuration files, server or location inside the block, add sendfile off;
- apt-get and apt-cache show command examples (Linux)
- Strategy Games Ubuntu installation of Wesnoth 1.12.1 (Linux)
- Java inheritance initialization problem (Programming)
- Sorting Algorithm (1) Quick Sort C ++ implementation (Programming)
- Moosefs Distributed File System Configuration (Server)
- CentOS install Memcached (Server)
- Linux configuration Samba server (Server)
- To install Jetty server configuration in detail (Server)
- CentOS 7 - use cgroups limit process resource (Linux)
- QBit development of micro-services (Server)
- MySQL use benchmarking tool sysbench (Database)
- Linux System Getting Started Learning: install software packages on Ubuntu and Fedora (Linux)
- Linux System Getting Started Learning: The Linux logrotate (Linux)
- C # assembly calls across constants, variables and functions (Programming)
- Source install Python3.4 on CentOS (Linux)
- How to install Wine 1.7.20 under Ubuntu or Linux Mint (Linux)
- C ++ two second pointer memory model (two-dimensional array) (Programming)
- Expert advice: Do not use the computer security IE browser (Linux)
- C ++ Supplements --new delete overload (Programming)
- Oracle 11g upgrade PSU detailed steps (Database)
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.