Home IT Linux Windows Database Network Programming Server Mobile  
           
  Home \ Server \ Use Vagrant up a local development environment tutorials     - Zabbix configuration external network mail alarm (Server)

- MySQL TIMESTAMP and DATETIME (Database)

- Node.js form --formidable (Programming)

- Java how to achieve bubble sort the problem Arraylist (Programming)

- Win8 mount disk partitions under Ubuntu (Linux)

- Java threads in the life cycle (Programming)

- Sort search algorithm Java - application examples with recursive dichotomy (Programming)

- Oracle Database High-Risk Vulnerability Warning (Database)

- jdbc Oracle database connection string writing pluggable (Database)

- Linux text processing tool of sed (Linux)

- Based LNMP + uWSGI deploy Django applications (Server)

- Linux and hardware (Linux)

- Linux System Getting Started Tutorial: How to Force Change your password at next logon Linux (Linux)

- Implement Oracle dynamic registration of non-standard port 1521 (Database)

- Cross server / client backup command: rsync use (Server)

- Use Nginx as a load balancer (Server)

- Linux file compression and archiving (Linux)

- using Docker Kitematic on windows (Linux)

- Linux input and output redirection (Linux)

- Linux command ls (Linux)

 
         
  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,

ready

Download and install the following two things:

VirtualBox
Vagrant
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

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
return:

==> 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
return:

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.

initialization

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
return:

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: 127.0.0.1:2200
    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
ssh

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:

ifconfig
return:

eth0 Link encap: Ethernet HWaddr 08: 00: 27: CE: 08: 3D
          inet addr: 10.0.2.15 Bcast: 10.0.2.255 Mask: 255.255.255.0
          inet6 addr: fe80 :: a00: 27ff: fece: 83d / 64 Scope: Link
          UP BROADCAST RUNNING MULTICAST MTU: 1500 Metric: 1
          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: 192.168.1.104 Bcast: 192.168.1.255 Mask: 255.255.255.0
          inet6 addr: fe80 :: a00: 27ff: fec4: aba1 / 64 Scope: Link
          UP BROADCAST RUNNING MULTICAST MTU: 1500 Metric: 1
          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: 127.0.0.1 Mask: 255.0.0.0
          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 192.168.1.104, which should be the virtual machine, including the network's IP address.

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

command

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.

Update


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 127.0.0.1, 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.

2014.08.04

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;
     
         
       
         
  More:      
 
- How to understand Python yield keyword (Programming)
- Compile and install LNMP under CentOS 6.5 (Server)
- Use Git in Eclipse (Linux)
- CentOS / Linux restart active NIC connection paths / network configure error Error Resolution (Linux)
- Comparison of C # and Java (Programming)
- Shell Script: Bulk add users, and set the random character password (Programming)
- Workspace Go language and environment variables GOPATH (Linux)
- iTerm - let your command line can also be colorful (Linux)
- Use virt-manager to create and manage virtual machines (Linux)
- Java and Python use make way dictionary word search script (Programming)
- Four levels of intrusion on Linux server and counter-measures (Linux)
- Build ftp server under CentOS 6.5 (Server)
- ImageMagick Tutorial: How to cut images in Linux command line (Linux)
- Difference Docker mirror and containers (Server)
- Java Concurrency: synchronized (Programming)
- Firewall chapter of Linux server security configuration (Linux)
- git checkout generated in the use of temporary br (Linux)
- Linux system using the command line shutdown or restart (Linux)
- Linux directory structure (Linux)
- Multi-core CPU, multi-threading and parallel computation (Linux)
     
           
     
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.