Install Apache Web Server on Ubuntu

Table of Contents

Install Apache Web Server on Ubuntu

This step-by-step howto shows a basic setup for Apache 2 web server. Apache is installed on Ubuntu 6.06 LTS Dapper, but instructions will probably work on any Ubuntu. This document is a work in progress, initially only required commands are listed without troughout explanations.

© 2006 Tero Karvinen. GNU General Public License, version 2.

Install Apache

$ sudo apt-get install apache2

Test it

Surf to your own server on your own local computer:

$ firefox "http://localhost"

Find out how your server is found on the net. Anyone can use your IP address or DNS name to connect to your server:

$ ip addr

Use your own IP address (eth0, first IP number, does not end .255)

$ firefox ""

If DNS is working on your network, you can see your fully qualified domain name with:

$ host

User homepages

With user homepages, anything you put in public_html in your home directory is published on the web.

Enabling Userdir on Server

For newer Ubuntu such as 8.04 Hardy, you have to explicitly enable userdir module. On older ones such as 6.06 LTS Dapper, userdir is enabled by default.

$ sudo a2enmod userdir
$ sudo /etc/init.d/apache2 restart

UPDATE 2016: On modern Linuxes such as Ubuntu 16.04, you can restart the server with:

   $ sudo service apache2 restart

Test homepages

Go to your home directory

$ cd

Create a folder for public html files, note the underscore ‘_’

$ mkdir public_html

Check your name

$ whoami

Surf to ~yourname:

$ firefox "http://localhost/~tkarvine/"

You should see a directory listing of an empty directory. You can also try it using your IP address and a different machine.

If you see your homepage, well done. You have successfully installed a server with user homepages. You can create some web pages with OpenOffice and save them to your public_html directory.

Posted in Old Site | Tagged , , , | 32 Comments

32 Responses to Install Apache Web Server on Ubuntu

  1. In most modern distros, daemons are restarted with

    $ sudo systemctl restart apache2.service

  2. Pingback: Aikataulu – Linux palvelimet ict4tn021 4-ti ja 5-to – alkusyksy 2017 – 5 op | Tero Karvinen

  3. Pingback: Aikataulu – Palvelinten hallinta ict4tn022-2 – 5 op, uusi OPS – loppukevät 2017 p2 | Tero Karvinen

  4. Pingback: Aikataulu – Linuxin keskitetty hallinta – ict4tn011-11 – loppukevät 2017 p2 | Tero Karvinen

  5. Pingback: h3 – Anssi Leväslampi's Blog

  6. Pingback: Aikataulu – Linux palvelimet ict4tn021 2-ti ja 3-ke – Alkukevät 2017 – 5 op | Tero Karvinen

  7. Pingback: Aikataulu – Linux palvelimet ict4tn021-1 – 5 op – alkusyksy 2016 | Tero Karvinen

  8. Pingback: Aikataulu – Linuxin keskitetty hallinta – ict4tn011-10 – loppusyksy 2016 | Tero Karvinen

  9. Pingback: Aikataulu – Linux palvelimena ict4tn003 22 ja 23 – alkusyksy 2016 | Tero Karvinen

  10. Pingback: Aikataulu – Linuxin keskitetty hallinta – ict4tn011-9 – loppukevät 2016 | Tero Karvinen

  11. Pingback: Aikataulu – Linux palvelimena ict4tn003-19 – loppukevät 2016 | Tero Karvinen

  12. Pingback: Aikataulu – Linux palvelimena ict4tn003-20 ilta – keväällä 2016 | Tero Karvinen

  13. Pingback: Aikataulu – Linux palvelimena ict4tn003-17 ilta ja -18 päivä syksyllä 2015 | Tero Karvinen

  14. Pingback: Apache ja virtuaalipalvelin | Linux palvelimena

  15. Pingback: Linux palvelimena, kotitehtävä 5: Apache & virtuaalipalvelin | Minttu-Maria Aalto

  16. Pingback: Linux Palvelimena kotitehtävä 4 | Metapaketti & Reprepro | Esa Eskola & Linux Palvelimena

  17. Pingback: Linux server, adding users, installing apache and ssh | ICT-opintoja ja niiden tuloksia

  18. Pingback: Linux palvelimena ICT4TN003-11 – H1 | Leino

  19. Pingback: Linux palvelimena – kertaus vanhalla kokeella | ajsalminen

  20. Pingback: Harjoitus 1 – Linux palvelimena | Jk Korpi

  21. Pingback: Linux palvelimena ict4tn003-11: Harjoitus 1 | Mikko Ikonen

  22. Pingback: Aikataulu – Linux palvelimena ict4tn003-11 ja -12 keväällä 2014 | Tero Karvinen

  23. Pingback: Aikataulu – Linuxin keskitetty hallinta – ict4tn011-4 syksyllä 2013 | Tero Karvinen

  24. Pingback: Aikataulu – Linux palvelimena ict4tn003-9 ja -10 syksyllä 2013 | Tero Karvinen

  25. Pingback: Aikataulu – Linuxin keskitetty hallinta – ict4tn011-3 | Tero Karvinen

  26. Pingback: Aikataulu – Linux palvelimena ict4tn003-7 keväällä 2013 | Tero Karvinen

  27. Pingback: Aikataulu – Linuxin keskitetty hallinta – ict4tn011-2 | Tero Karvinen

  28. Pingback: Aikataulu – Linux palvelimena ict4tn003-4 ja ict4tn003-6 syksyllä 2012 | Tero Karvinen

  29. Pingback: Aikataulu – Linuxin keskitetty hallinta – ict4tn011-1 | Tero Karvinen

  30. Pingback: Update All Your Computers with a .DEB Repository | Tero Karvinen

  31. Irina Shapovalova says:

    the “$ mkdir public_html” command does not mention that it should be created under root… it took some time for me as a beginner to figure it out.

    • ‘mkdir public_html’ should be run in user’s home directory. The previous command in the article is ‘cd’, which takes you to your home dir.

      For example, your home page could be under /home/irina/public_html/.

      You should never create public_html directly under root directory ‘/’.

Leave a Reply

Your email address will not be published. Required fields are marked *



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • Picks

  • Boxing Clock for AndroidOcton8 Diving T-ShirtsShaking Tower Panda Android GameLearn Chinese with Android
  • Student projects