In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to install cross-platform team development tools Vagrant under Linux system". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Vagrant is a tool to create a lightweight, highly reusable, and portable development environment.
In the eyes of non-professionals, this means that Vagrant abandons all the headache settings in the development environment and replaces them for a single configuration file, and you can choose the features that your server needs to retain. You will no longer be stuck by XAMMP, manually configuring virtual environments, or using FTP remote editing.
Vagrant is a powerful tool, and its function and value are beyond the scope of this article and my understanding. This article will introduce some pretty cool things in Vagrant, such as:
Use the PHP5.4 version of LAMP on your machine.
How to easily access the database in your virtual machine.
How to update your hostfile automatically, use URL to reference the developing on http://localhost:8080 versus http://myprojectname.local).
Some necessary Vagrant commands.
The best and most useful Vagrant plug-ins.
Link to more resources and pre-built Vagrant stacks.
Imagine that you are developing an application with a team of 15 people. This program is awesome! It uses Laravel's PHP framework, Redis and Memcached,ImageMagick and GD's PHP modules, curl,MySQL and PostgreSQL, and even MongoDB. In addition, Laravel explicitly relies on PHP version 5.3.7 or later, as well as mcrypt's PHP extension.
Ideally, you would want all 15 people on the team to develop this application in the same development environment. But not all development teams have system management experts or train a system management. Getting a development environment with the same settings can be a daunting task. Most importantly, some people use Mac, while others use Linux or Windows. Before it, developers would be obsessed with endless configurations and exhausted by throwing computers at the wall.
Vagrant will manage the environment settings for you, allowing you to focus on the development of business code.
In another scenario, more than half of the project has been developed and found that Beanstalkd needs to be installed to deal with queue problems. Usually, people stop to reconfigure the environment and expect Bean stalkd to work properly. With Vagrant, you just need to push the update file to the configuration file, and everyone just needs to refresh the Vagrant. great! Then you can use the queue function. This has nothing to do with the operating system, whether it's Windows, Linux, or Mac, because everyone's operating environment is the same.
Installation steps
1. Install VirtualBox
Virtual machines still have to rely on VirtualBox to build, free and small.
Download address: https://www.virtualbox.org/wiki/Downloads
* although Vagrant also supports VMware, VMware is charged, and the corresponding Vagrant version is also charged.
two。 Install Vagrant
Download address: http://downloads.vagrantup.com/ install step by step according to the prompts.
In addition, you need to download the official packaged basic image:
Ubuntu precise 32 VirtualBox http://files.vagrantup.com/precise32.box
Ubuntu precise 64 VirtualBox http://files.vagrantup.com/precise64.box
If you want images of other systems, you can download it here: http://www.vagrantbox.es/
* in view of the domestic network speed, we have stripped out the steps of downloading the image separately.
3. Add Mirror to Vagrant
Suppose the storage path of the image we downloaded is ~ / box/precise64.box, enter it in the terminal:
The code is as follows:
$vagrant box add ~ / box/precise64.box
is the name we gave this box, and ~ / box/precise64.box is the path where box is located.
4. Initialize the development environment
Create a development directory (for example: ~ / dev). You can also use the existing directory, change to the development directory, and initialize the environment of the current directory with image:
The code is as follows:
$cd ~ / dev # switch directories
$vagrant init # initialization
$vagrant up # launch environment
You will see that the terminal shows the startup process, and after booting is complete, we can log in to the virtual machine with SSH. The remaining steps are to configure the various environments and parameters that you want to run in the virtual machine.
The code is as follows:
$vagrant ssh # SSH login
$cd / vagrant # change to the development directory, that is, `~ / dev` on the host
The directory in the virtual machine corresponding to the dev directory is / vagrant.
Note to Windows users: ssh is not supported on Windows terminals, so you need to install third-party SSH clients, such as Putty, Cygwin, etc.
5. Other settin
After Vagrant initialization is successful, a Vagrantfile configuration file will be generated in the initialized directory, which can be modified for personalized customization.
By default, Vagrant uses port mapping to map the ports of virtual machines locally to achieve access like http://localhost:80, which is troublesome and has to be edited when new ports are opened or modified. In comparison, the host-only mode is much more convenient. Open Vagrantfile, remove (remove #) the comments on the following line, and save:
The code is as follows:
Config.vm.network: private_network, ip: "192.168.33.10"
Restart the virtual machine so that we can access the machine with 192.168.33.10, and you can change the IP to a different address, as long as there is no conflict.
6. Package distribution
When you have configured the development environment, exit and shut down the virtual machine. Package the development environment in the terminal:
The code is as follows:
$vagrant package
After the packaging is completed, a package.box file will be generated in the current directory and passed to other users, who can get an identical development environment by adding the box and initializing their own development directory.
7. Common command
The code is as follows:
$vagrant init # initialization
$vagrant up # start the virtual machine
$vagrant halt # shut down the virtual machine
$vagrant reload # restart the virtual machine
$vagrant ssh # SSH to the virtual machine
$vagrant status # View the running status of the virtual machine
$vagrant destroy # destroy the current virtual machine
For more information, please refer to the official document http://docs.vagrantup.com/v2/cli/index.html
8. Matters needing attention
When using Apache/Nginx, situations such as image modification but page refresh are still old files occur due to static file caching. The Apache/Nginx configuration file in the virtual machine needs to be modified:
The code is as follows:
# Apache configuration add:
EnableSendfile off
# Nginx configuration add:
Sendfile off
This is how the SegmentFault team unifies the development environment.
This is the end of the introduction to "how to install the cross-platform team development tool Vagrant under Linux". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.