Save it to your desktop as index html

Download 16.5 Kb.
Hajmi16.5 Kb.


These are the steps needed to create an Apache HTTP web server running in a virtual machine.

First of all, grab some html code and edit it in Notepad to use as a test website.

Save it to your desktop as index.html

If you were to double click on this icon, your default web browser would fire up and the web page would be displayed:

This the best way to create and test your website before using it in your Apache HTTP server.

Now we want to save that as a file in an Apache server running in a virtual machine.

Download the Oracle open source virtualization software Virtualbox. Once that is up and running, go grab the open source Ubuntu Linux server LTS and save the .iso image on your desktop or burn it to a disc.

Start a new virtual machine in Virtualbox (“New”) and install (“Show”) the Linux server. When running through the configuration, install the LAMP packages. LAMP stands for Linux, Apache, MySQL and PHP.

Once installed, start up Ubuntu Linux server.

For the index.html file to be served from the correct target directory, we need to first get to the proper file location and then create a directory where the files will be saved. Once that is done, then at the $ prompt, we will start the nano editor in the file to be created and saved. The default directory where websites are served in Ubuntu Linux Server LTS 14.04 is /var/www. The default webpage is at /var/www/html/index.html.

cd var/www

We want a new directory to hold each of 3 separate websites:

sudo mkdir websites

Enter password

cd websites

sudo mkdir site1 site2 site3

Then change to the directory to hold the first website

cd /site1

This is a placeholder for a future project where we will use the virtual host mechanism in Apache server to host several websites at the same IP Address.

Now we want to start the nano editor and type in the test website. Be sure to use $ sudo nano to be able to save your work.

$ sudo nano

Enter your Ubuntu password

Then type in your HTML Code and save it as index.html using nano command Control O.

Then exit out of nano using nano command CTRL X.

To be able to see a webpage within your Ubuntu Linux server, you need a rudimentary web browser.

W3M is a good one.

Back at the initial log in:

sudo apt-get install w3m w3m-img

Enter password and once installed, check it by running w3m with a webpage URL such as google:

Now you can test localhost to see the default webpage:

$ w3m localhost

Now we can ping the saved file at site 1 to /var/www/websites/site1/index.html to get our website:

By moving the cursor to the link, and hitting enter, it will take us to the referenced website in w3m:

We can also access the default webpage by going to Finally, we can see what the IP address of the server is by entering:

$ ifconfig

Then getting the IP Address:

Here, you see it under the main Ethernet interface eth0. By plugging in that IP Address:, it takes us to the default webpage.

So we know that the code is sitting there, now we need to be able to ping it from outside the Apache webserver from a host. To get out of W3M, hit Ctrl z:

In our later project we will edit the global .conf files to allow those outside the private network to access the webpage.

To check on which ports are open and are LISTENING, type:

$ netstats –an | more

You can see our instance of Apache server does not appear to be listening for all IP V4 IP addresses at tcp port 80. Thus, perhaps Apache server needs to be started or restarted.

To start, type in /etc/init.d/apache2 start

Or type in etc/init.d/apache2 restart

Now we are going to go to where webpages are kept, which is /var/www/:

$ cd /var/www/

Then you can list the files in there using the command ls-a:

So now we need to get the file we saved at /var/www/websites/site1/index.html and save it at /var/www/html/index.html [Note, your files may be saved at a different location]

$ sudo nano /var/www/websites/site1/index.html

Enter your password, then:

Save as /var/www/html/index.html

Enter: Ctrl O

Then edit to save at new location:


Type Yes to Overwrite. Then check to see if your new website is there.


$ clear

Then $ w3m localhost:


Now we need to be able to let others access this website from outside the server.

First I note that when I fire up Firefox outside the Virtualbox virtual machine that is holding the Apache server, I am not able to access the website

I check the IP Address of the host machine (as assigned by DHCP) and it is

These are on 2 different subnets. So we need to assign the VM a static IP Address in the same subnet,

Right now DHCP is assigning the IP Address. We want to change that to a static IP Address using nano.

$ sudo nano /etc/network/interfaces

Now we can edit this file:

Need to save using CTRL X and yes to overwrite and Enter

Now we need to restart apache2:

$ sudo /etc/init.d/networking restart

Test the webpage by entering in new IP Address.

$ w3m

No joy. So I looked at the Virtualbox settings. I changed this:

To this:

Did Restart again:

Still no joy, so I shut down the VM and started it up again:

And success. The moral, don’t get discouraged, keep trying until you find the answer to the problem at hand.

As you can see, the new IP address information has taken effect.

Now we can test again using w3m:

Finally, now to test outside the webserver (effectively, a host outside the webserver). Fire up a web browser outside of Virtualbox and enter in the new static IP address—here


Download 16.5 Kb.

Bosh sahifa

    Bosh sahifa

Save it to your desktop as index html

Download 16.5 Kb.