The Mind of Scott

space walk
Its a virtual cake walk!

Setup an easy web server with Ubuntu 12

Learn how to setup a super easy web server with Ubuntu 12. No computer needed and the required software cost nothing. Use your free LAMP server (a type of web server) to learn Linux, html or web development, web server creation and administration. Also learn about server virtualization. Almost all IT including the cloud is now dependent on virtualization. Learn how to build a website from scratch.

Learning LAMP

Below, find instructions for a super easy setup of a learning LAMP (stands for Linux, Apache, MySQL and PHP). LAMPs are essentially database enabled web servers on Linux.

Server Virtualization and the Cloud

We will setup a virtual computer to run our web server using Oracle VirtualBox. This is a great piece of software and its free! Just as computers can run virtual calculators, virtual TVs, virtual radios and virtual music players, so to can VirtualBox run a virtual computer -within your physical computer. Once setup, your virtual website cannot be accessed from the Internet unless your ISP allows it. But you can get to it from your local windows computer. Like I said, this is how to create a learning website.

These virtual machines can easily be copied, deleted and created. Also, you can save the entire virtual machine's state (called a snapshot) at one point in time and then revert to that state if you screw up the machine. These are important concepts of virtualization.

Requirements

The steps below were tested on an old Dell XPS with Windows XP, a few GBs of ram and a wired connection. For 64 bit just select 64 bits where applicable including the download of 64bit Ubuntu server. I was able to set it all up in about 30 minutes. Some easy, no-brainer steps were left out.

This procedure requires you to have a very basic understanding of the command line and you should know what an IP address is.

PART 1: Download and install VirtualBox. Download Ubuntu Linux.

STEP 1: Download and install Oracle VirtualBox on your Windows machine.

STEP 2: Download Ubuntu 12.04 Server (not desktop) unless you have 64bits. You need the ISO file named ubuntu-12.04.1-server-i386.iso. Yes, its big. An ISO file is essentially a virtual DVD with Ubuntu on it.

STEP 3: Open up VirtualBox and click new.

STEP 4: Give it a Name (remember this name) and select Linux as the type. Select Ubuntu as the version.

virtualbox

STEP 5: Take default values for other questions. Use 512Mb of memory. That is fine for a learning machine.

STEP 6: Select create a virtual hard drive now. 8GB will be more than enough space but you can reduce it down to 4GB.

PART 2: Install Ubuntu in your virtual machine

STEP 1: You have created the virtual machine but now we need an operating system installed. Select your new machine on the left and click settings. When powered off your virtual machine is nothing more than a big file on disk.

virtualbox

STEP 2: Click storage and then the DVD icon that says Empty. See red circle on left.

STEP 3a: Click the icon to the right of the CD/DVD Drive field. See red circle on right. Then select Choose a virtual CD/DVD disk file ... Browse to the Ubuntu iso file that you downloaded and select it. (You let the download finish, right?) Your virtual machine will boot off this ISO!

virtualbox

STEP 3b: Still in settings, click Network. Select Bridged Adapter in the Attached to: drop down field.

STEP 4: Click ok to close settings.

STEP 5: With your virtual machine selected click the Start button. If Virtualbox displays pop-up messages glance over them. Most of these pop-up messages are warnings and do not require you to do anything.

STEP 6: Now run through install of Ubuntu server. Its rather easy. Other sites have precise steps but I'll mention only the somewhat tricky parts of the install here. If you are unsure how to answer just take the default unless I otherwise specify here. Also, if the install goes to hell, you can delete the virtual machine and start over.

STEP 7: On the first install screen select language then on the next screen select Install Ubuntu Server then select keyboards, languages (again) and other stuff. The install option may timeout and auto-select before you can read it. If it does just keep going.

STEP 8: Give it a hostname of about 10 characters and remember it.

STEP 9: Give it a username and password. Do you need to write this down?

STEP 10: For disk select "Guided - Use entire disk."

STEP 11: The scary question "write changes to disk" refers to the virual disk in the virtual machine only. Answer Yes. Your computer will be unharmed and if it does get messed up its on you --not me.

STEP 12: Whoa! when you get to the install screen that says "Software Selection" at the top, use the arrow key to move down to "LAMP Server" and hit the space bar! You should see "LAMP Server" selected with an asterisk. I suggest that you NOT install anything else unless you fully understand the software.

STEP 13: Install GRUB, you'll be okay.

STEP 14: Did you select "yes" to overwrite master boot record? NO! NO! You just F'ed up the whole computer! OMG! Just kidding.

STEP 15: You probably do not need to unmount the ISO in settings. Just let it reboot. Your virtual web server will boot in its own little window. Click in that window. Use right Ctrl button to get cursor out of that window!!! Your web server will behave just like a physical computer.

PART 3: Download and install a FTP server and also install a FTP client.

STEP 1: Start your virtual machine and login if its does not auto start.

STEP 2: This is what we call a headless server. No wonderful windows just a command line and, yeah, you need to learn a few Linux commands.

virtualbox

STEP 3: Ultra-fast Linux command line lesson:

STEP 4: Look at eth0's IP. Can you ping it from a windows command line? Example: ping 192.168.1.5

STEP 5: Try pinging google.com from the Linux command line. Example: ping google.com

STEP 6: If you cannot ping, did you do part 1 step 3b correctly? Did you choose Bridged Adapter so that your server could access the Internet? Is your router setup to dole out a DHCP address to the Linux machine? Your ISP should have given you a router to do this.

STEP 7: Ultra-fast lesson in the ever present text file editor called vi. No, there is no graphical editor on a headless Linux server. If you install the FTP server you may need to edit the configuration file using vi.

STEP 8: You need a FTP server app on your new LAMP so you push html files up to it from your windows machine. Use vsftp! Google "Install FTP Server with vsftpd on Ubuntu 12.04 Precise Pangolin" and read the excellent article Setting up vsftpd .

STEP 9: You also need a FTP client. Install the excellent Firefox addon called FireFTP. In Firefox, Tools, Web Developer and FireFTP. Select "create an account"..Enter a name and other connection information including the virtual machine's IP address to configure the host on the connection tab in FireFTP. Also, configure the local and remote directories on the connection tab. The remote directory should be /var/www. This is where all your html will go. Go there using the Linux command line and list files. The file index.html is the html file that will display the first webpage people see when they go there.

PART 4: Create a webpage on your new LAMP

STEP 1: Open a browser and enter your virtual machine's IP address in the URL field and press enter.

STEP 2: Use FireFTP to pull down index.html. Change the text message with notepad and push it back up.

STEP 3: If everything is running good then it is strongly recommended you do a snapshot or that you clone your machine. Doing one of these two things is like saving your machine in its current state. If you screw it up, you can revert to the way it was without having to rebuild the whole thing. In the virtual machine's Machine drop down menu do a snapshot OR with the machine powered off clone it. A linked clone is faster but dependent on the original machine for its existence.

STEP 4: You don't like headless servers? Want a pretty windows-like desktop? The desktop will take a very long time to install (hours maybe), and slow down the system and if you only want to build html on your web server then you don't need it. If however you want the pretty, wuss's desktop: From a Linux command line enter: sudo apt-get install ubuntu-desktop and answer questions.

virtualbox


Tech Stuff Page

Home