[Front Page] Article: DIY: Virtual Servers, Secure Web Hosts, And You.

fly

omg
Oct 1, 2004
76,252
26,119
1,323
Marklar
₥64,619
Steam
mattressfish
Time to #getyournerdon. Duke is gonna school you on how to get your own web hosting setup. Strap in for Part 1 of the series. Thanks for putting all this together!


DIY: Virtual Servers, Secure Web Hosts, And You.


Back in the early days of the web, setting up a webpage was easy. Virtual hosting sites were everywhere, and simple HTML and Frames ruled the day. Setting up web pages was a breeze. Then came javascript, and flash, and html 5, and php, and a load of other components that brought these simple web pages to life. All at the same time, various malcontents and micreants of the virtual playground took to the web looking for new fodder to test their hacking skills. Co-opting a base level webserver was common, and childs play.

Skip to today, where setting up your own web hosting solution is a more complex task than in the past, and one not normally taken on by a casual hobbiest. However, taking the path of learning the basics of setting up a secure web server will introduce and familiarize with many skillsets used in the market today. Even as a hobbiest, having your own web server to use at your will gives you the ability to play around with new blog cutomizations, or development environments to fine tube a website you may be working on before deploying to a live server.

Going 'Virtual'

In many hosting environments today, if you wish to 'bring your own box' so to speak, you will typically be assigned a 'virtual server'. Virtual servers are commonplace in todays network world as they allow multiple servers (which in the past typically each existed on their own physical platform) to run in parallel with others, all sharing a singular hardware platform. In the business world, hi tech implimentations are used to save money through hardware and support savings. In the hobbiest world, what it means is that you can create as many PC configurations as you like and easily swap between them, in essence, giving you unlimited 'junkers' to image and build to your hearts content.

One immediate benefit to a person studying for a MS certification. Most of microsofts enterprise level applications can be downloaded for 30-60 day trials. By using virtual PCs, you can set up a wonderful test environment to use as a realm for study 100% free of charge.

We're going to use VirtualBox for our virtual solution. MS VirtualPC has some issues with recognizing hardware virtualization in some boxes making installs, expecially 64 bit installs, difficult.

You can download it from this location.
VirtualBox by Oracle

Assuming you are running windows, click the executable for VirtualBox 4.2.4 for Windows hosts, download, and install. Make whatever changes you feel necessary (install location, etc). Once installed, go ahead and launch the Oracle Vm Virtualbox Manager.

vEdRS.jpg


Pretty sparse so far. Don't worry, soon it will have all kinds of info. For the time being, let's get your first virtual up and running. Click on that big blue button that says 'New'.
You will be presented with a screen asking you to name this virtual. Call it what you want, but it's helpful if the names are clear as to what the virtual is. Don't worry, this won't translate to an actual system name later. That's configured in the OS. Be sure to specify Linux & Ubuntu at this screen.

YNAas.jpg


Set the memory size to 1024 (512 is fine for 4gb or less systems.) when prompted and hit next to continue. Also go ahead and accept the initial default answer (which should be Create a Virtual Hard Drive Now). Choose .VHD (more on that later), and allow for dynamic scaling (also more on that later) and proceed. For the time being, keep selecting the defaults. Eventually, the virtual will be created, and you will see the following.

OLn4f.jpg


From here, you can see the general config of your new virtual machine.

At this point, we are ready to install our Webserver OS.

We'll be using a linux variant, Ubuntu 12.04 server, for our install. On top of it also being free (so far, you have gotten a free set of PCs in the virtualbox, and a free Server OS from this article, and you have barely lifted a finger. Benefits abound!) Besides the obvious benefit of 'Free', the flavor of choice on the internet is a linux/unix solution. Windows carries it's own flavor of web server, with lots of hooks and integrations to make it attractive to a windows dedicated user, but it's not the optimal option. Being skilled with Linux server installs in virtual environments is a viable resume line item for any IT type.
We are going with the server variant instead of Ubuntu desktop. The command line is your friend, and learning to use it will make your interactions with the server much faster, and will give you better egress to other roads of self knowledge as you play around more with the guts of your linux install.

Download Ubuntu Server 12.04 LTS here. There are newer flavors available, but 12.04 lts is the supported vertsion at this time.
Once the VHD has it's initial config, it's install time. Click on the biog green Start Button. (it's extremely technical). You will get a prompt about key overrides. Basically, it's telling you that all keyboard input will be captured to the virtual instal if it's window is active. If the window isn't active, the keyboard will respond with your desktop applications normally. The right CTRL key will allow you to bypass the key capture when held down while typing. After, tell the install the location of the Ubuntu Server ISO you downloaded.

You 'might' notice an error message during install. “This kernel requires an x86-64 CPU, but only detected an i686 CPU. Unable to boot – please use a kernel appropriate for your CPU”. Depending on the processor you have, you will need to go into the BIOS of your pc (which will require a reboot so save whatever you have open), and enable either Intel VT-x or AMD-V from BIOS (usually under a virtualization heading). Some flavors of AMD processor hide this under a section calls SVM (secure virtualization mode). Enable in your bios and this error should clear.

From this point, just select all the default Ubuntu install options (feel free to change what you wish along the way but for purposes here, we aren't going to do much personalization up front beyond what is required for address resolution). Various VirtualBox messages may pop up about 32bit colors, and other things. For the most part, just click OK.

When prompted, give your virtual it's name. This is what it will be known as on your network.

Huwk6.jpg


Other prompts will ask you for a user name (other than admin. This is your normal login), password, location info, etc etc.
Once the install is complete, go ahead and log in (you did write down the username and password you assigned just a few minutes ago, I hope). We have to get the OS updated in a few places, starting with Ubuntu's repositories.

from the prompt, enter sudo /bin/bash

You will see the prompt cursor change from '$" to '#' after successfull entry of the root password.

Type the following commands. This will recurse and upate repository information and add the package add-apt-repository.

aptitude update (aptitude is the new apt-get)
aptitude install python-software-properties

9BejD.jpg


The reason for this is that we need to add a new repository to Ubuntu to get the latest version of Nginx (pronounced Engine X). We will be using Nginx instead of Apache for the web server. Primary reason is that Nginx will give better performance in a virtual environment based on how it handles threads. It's less featured, but we won't need many. The lower overhead will equate to better performance on our virtual.

So, let's update Ubuntu so it knows where to find the new Nginix code. (add-apt-repository ppa:nginx/development); Update your sources (aptitude update); and install the nginx webserver (aptitude install nginx).

Once this is complete, shut down your virtual with the #poweroff command. We'll need to make a change to the way it's NIC is configured to allow us to see it's webserver from any machine on the network. To do this, go into settings > Network and in the tab for adapter 1, change 'attached to' from NAT to Bridged. This will give your virtual Linux install a real address on your private network, making it accessible via IP to other workstations. This will be helpful as we go along as this virtual eventually will sit in the background and only be interacted with via toolsets.

oDmai.jpg


Restart the virtual and login.

from the command prompt, type IFCONFIG. Notate the IP address given to your virtual.

From you PC (not the virtual) open a web browser and type in the IP address of your virtual. The IP addresses should be on the same class C network all things being typical. (this determined by the first 3 of the 4 octets of your IP matching. example 10.1.1.125 and 10.1.1.56 are on the same class c (10.1.1.x). 10.1.1.125 and 10.1.7.2 are not. (10.1.1.x != 10.1.7.x) . If you type in the ip address and all is working (as it should be) at this point you will see "Welcome to nginx!" appear in large letters in your browser.

Congratulations. The easy part is behind us.

:omy:
 

CletusJones

CUCKGBLR
Oct 15, 2004
16,870
707
548
Marklar
₥240
Ooh, fancy.

Why not use VMware? It's also free and works well. I've used both with good luck.

Why not use the synaptic package manager for your update/upgrade? This is an article for noobs, GUI is easier to operate for new users.
 

fly

omg
Oct 1, 2004
76,252
26,119
1,323
Marklar
₥64,619
Steam
mattressfish
Ooh, fancy.

Why not use VMware? It's also free and works well. I've used both with good luck.

Why not use the synaptic package manager for your update/upgrade? This is an article for noobs, GUI is easier to operate for new users.

I personally prefer VirtualBox because its open source.


edit: VMWare probably just pulled my cert for saying that. :lol:
 

Duke

. . first name's "Daisy" boys
May 12, 2008
55,859
18,144
41
Brandon, FL
Marklar
₥36,197
Fair enough, I was curious if you had any reason in particular

For the most part, not really. Just took what I was most familiar with.

I used virtual box for this discussion, although I actually use a Hyper-V server I built at home for running all of my servers. I mostly use virtual box as a sandbox platform if I'm playing with risky files/configs to be sure they are safe before I roll them out to my main box, but in this case it worked just as easily.
 

CletusJones

CUCKGBLR
Oct 15, 2004
16,870
707
548
Marklar
₥240
I haven't played with hyper-v, I don't have hardware at home for that anymore. Been using both VMware and Virtualbox and free for free, VB has more functionality than VMW. VB certainly inserts itself less places in your os.
 

Duke

. . first name's "Daisy" boys
May 12, 2008
55,859
18,144
41
Brandon, FL
Marklar
₥36,197
Hyper V is probably what I would choose for headless installs, or configs where you might need to RDP/SSH into from time to time but otherwise won't need to directly interact with. It's perfect for a SQL server, exchange server (in small sized or non production environments), etc. It's actually easy to set up a HyperV server. I have a 4 year old Dell Mid-Tower I stuck 3TB of drives & 16GB of ram on. Enabled virtualization in the bios, and Boom. I run a small footprint Dell as my PDC outside of the HyperV server to avoid any replication issues.

If I need an actual interactive desktop, I'd probably stick with VirtualBox. I currently have a Linux & Win 8 VirtualBoxs that I call up from time to time but don't use regularly.