Read the Beforeitsnews.com story here. Advertise at Before It's News here.
Profile image
By Sunlight Foundation Blog (Reporter)
Contributor profile | More stories
Story Views
Now:
Last hour:
Last 24 hours:
Total:

System administration for junior devs: Setting up a virtual server with Vagrant

% of readers think this story is Fact. Add your two cents.


By The Sunlight Foundation

When you’re learning about system administration, it is helpful to have a private server to muck around on so that your mistakes do not affect users. Fortunately, you can use a tool called Vagrant to easily create virtual servers on your development machine. This tutorial requires Vagrant, so you will need to follow these instructions if you do not have it already (it is pretty easy). You will also need VirtualBox.

This blog post aims to help developers create a virtual server while also explaining what, exactly, that means.

1. Creating a clean virtual server

For this tutorial, I have predefined some very vanilla Vagrant settings to get things started. To grab those, run git clone https://github.com/handlers/servers.git.

Now cd into that directory. ls and you’ll see that the repository has a Vagrantfile which contains details about the server that Vagrant is going to create. If you poke around that Vagrantfile and ctrl + f for “config.vm.box,” you should see a line that looks like this: config.vm.box = "ubuntu/trusty64". This tells Vagrant that our server should come preloaded with the Trusty release of the Ubuntu operating system. You should also note that this Vagrantfile specifies a private IP address of 192.168.33.11.

2. Creating your virtual server

We will now use Vagrant to create a virtual server on your computer. Make sure you’re in the project directory you cloned from GitHub and run vagrant up. (It may take a while to download the Ubuntu base image.1) Eventually your terminal should spit out something like this:

==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...

3. What it means to have a virtual server

When you run vagrant up, you create something that walks and talks like a real server, but it is actually running within your own computer. For our purposes, it is important that the virtual server is networked. We can prove it by pinging the IP referenced in the Vagrantfile (192.168.33.11).

$ ping 192.168.33.11
PING 192.168.33.11 (192.168.33.11): 56 data bytes
64 bytes from 192.168.33.11: icmp_seq=0 ttl=64 time=0.385 ms
^C
--- 192.168.33.11 ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.385/0.385/0.385/0.000 ms

As you can see, we are getting packets back from the IP address we just created.

Vagrant also preloads the machine with a user named vagrant, and you can ssh into the machine as this user. Try running vagrant ssh from within the project directory.2 You should see a prompt like this:

vagrant@vagrant-ubuntu-trusty-64:~$

It allows you to do everything you can do on a regular server, from checking out the machine’s OS to poking around its directory structure.

“`
vagrant@vagrant-ubuntu-trusty-64:~$ uname -a
Linux vagrant-ubuntu-trusty-64 3.13.0-39-generic #66-Ubuntu SMP Tue Oct 28 13:30:27 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

vagrant@vagrant-ubuntu-trusty-64:~$ pwd
/home/vagrant

vagrant@vagrant-ubuntu-trusty-64:~$ ls /
bin dev home lib lost+found mnt proc run srv tmp vagrant vmlinuz
boot etc initrd.img lib64 media opt root sbin sys usr var
“`

You now have a virtual Ubuntu server running on your computer, complete with ssh access. cd / and take a little time to check out what’s going on. It might be helpful to check out this Wikipedia article on Unix’s normal directory structure. Many, many websites run on computers that have directories laid out like this. Don’t worry about messing some part of your server up — creating a fresh image is as easy as bringing down your existing server with vagrant destroy and then running vagrant up again. Remember that these commands (vagrant ___) should be issued from your computer, not from within the virtual machine.

You have now completed the first step in understanding how your server fields Web requests, creating a very basic, networked virtual server. You are controlledly replicating the Internet on your development machine. Stay tuned for part III, in which we configure our server to handle HTTP requests with NGINX.

Extra credit

If you really want to get down into the guts of what’s going on, try sshing into your virtual server and running tcpdump -i any icmp[icmptype] == 8 to see what happens when you ping it. It is pretty cool!


1 The wait is more bearable when you realize you are basically downloading a whole computer!
2 It is worth noting that you did not run your system’s standard ssh command, but rather a Vagrant utility called ssh which opens a shell session on the virtual machine. You can, however, also run ssh [email protected] with password vagrant.

The Sunlight Foundation is a non-profit, nonpartisan organization that uses the power of the Internet to catalyze greater government openness and transparency, and provides new tools and resources for media and citizens, alike.


Source: http://sunlightfoundation.com/blog/2015/05/12/system-administration-for-junior-devs-setting-up-a-virtual-server-with-vagrant/


Before It’s News® is a community of individuals who report on what’s going on around them, from all around the world.

Anyone can join.
Anyone can contribute.
Anyone can become informed about their world.

"United We Stand" Click Here To Create Your Personal Citizen Journalist Account Today, Be Sure To Invite Your Friends.

Before It’s News® is a community of individuals who report on what’s going on around them, from all around the world. Anyone can join. Anyone can contribute. Anyone can become informed about their world. "United We Stand" Click Here To Create Your Personal Citizen Journalist Account Today, Be Sure To Invite Your Friends.


LION'S MANE PRODUCT


Try Our Lion’s Mane WHOLE MIND Nootropic Blend 60 Capsules


Mushrooms are having a moment. One fabulous fungus in particular, lion’s mane, may help improve memory, depression and anxiety symptoms. They are also an excellent source of nutrients that show promise as a therapy for dementia, and other neurodegenerative diseases. If you’re living with anxiety or depression, you may be curious about all the therapy options out there — including the natural ones.Our Lion’s Mane WHOLE MIND Nootropic Blend has been formulated to utilize the potency of Lion’s mane but also include the benefits of four other Highly Beneficial Mushrooms. Synergistically, they work together to Build your health through improving cognitive function and immunity regardless of your age. Our Nootropic not only improves your Cognitive Function and Activates your Immune System, but it benefits growth of Essential Gut Flora, further enhancing your Vitality.



Our Formula includes: Lion’s Mane Mushrooms which Increase Brain Power through nerve growth, lessen anxiety, reduce depression, and improve concentration. Its an excellent adaptogen, promotes sleep and improves immunity. Shiitake Mushrooms which Fight cancer cells and infectious disease, boost the immune system, promotes brain function, and serves as a source of B vitamins. Maitake Mushrooms which regulate blood sugar levels of diabetics, reduce hypertension and boosts the immune system. Reishi Mushrooms which Fight inflammation, liver disease, fatigue, tumor growth and cancer. They Improve skin disorders and soothes digestive problems, stomach ulcers and leaky gut syndrome. Chaga Mushrooms which have anti-aging effects, boost immune function, improve stamina and athletic performance, even act as a natural aphrodisiac, fighting diabetes and improving liver function. Try Our Lion’s Mane WHOLE MIND Nootropic Blend 60 Capsules Today. Be 100% Satisfied or Receive a Full Money Back Guarantee. Order Yours Today by Following This Link.


Report abuse

    Comments

    Your Comments
    Question   Razz  Sad   Evil  Exclaim  Smile  Redface  Biggrin  Surprised  Eek   Confused   Cool  LOL   Mad   Twisted  Rolleyes   Wink  Idea  Arrow  Neutral  Cry   Mr. Green

    MOST RECENT
    Load more ...

    SignUp

    Login

    Newsletter

    Email this story
    Email this story

    If you really want to ban this commenter, please write down the reason:

    If you really want to disable all recommended stories, click on OK button. After that, you will be redirect to your options page.