Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

It's very hard to find comprehensive information on this subject. Either I found short tutorials on how you perform the installation, as simple as "apt-get install apache2", or outdated tutorials. So I was hoping I could get some professional information from my fellow members of the Ubuntu community :D

I have performed a normal Ubuntu Server 11.04 with LAMP, SAMBA and SSH installed through the system installation. But I'm having some trouble setting up virtual hosts and to make the system secure enough to expose the server to the web.

I've somewhat followed this tutorial this far.

I have 3 sites in /etc/apache2/sites-available which all looks like this except for different site names:

   ServerAdmin webmaster@localhost
   DocumentRoot /var/www/sites/example
   CustomLog /var/log/apache2/ combined

And I have enabled them with the command a2ensite so I have symbolic links in /etc/apache2/sites-enabled.

My /etc/hosts file has these lines: localhost Ubuntu.lan Ubuntu localhost.localdomain localhost localhost.localdomain localhost localhost.localdomain localhost

And I can only access one of them from the browser (I have lynx installed on the server for testing purposes) so I guess I haven't set them up properly :)

How should I proceed to get a secure and proper setup? I also use MySQL and I think that this tutorial will be enough to set up SSH securely. Please help me understanding Apache configuration better since I'm new to setting up my own server (I've only run XAMPP earlier) and please advise regarding how I should setup a firewall as well :D

share|improve this question
You might also ask at, a StackExchange for setting up and maintaining servers and systems. – Kris Harper Sep 6 '11 at 19:48
A correct answer to this can fill books. I would suggest to split your question into some regarding configuration of virtual hosts and security. A good answer to security-related questions relates to a good knowledge of your attackers, of your users and some other. – qbi Sep 6 '11 at 20:45
Thanks, I will check out serverfault if I can find any good answers! :) – Niklas Sep 8 '11 at 6:54

You need to tell Apache that it should use name-based virtual hosting instead of IP based. So append the following to your /etc/apache2/apache2.conf to define:

NameVirtualHost ip.address:port

And each virtual host should define a port:

share|improve this answer

I think you'll need to add your public IPs as well if you want other computers to be able to connect. Right now, only your loopbacks are mentioned in /etc/hosts. They should also include other IPs.

share|improve this answer
Are you sure? Wouldn't it be enough if I just get my Domain Name Server to point to my IP and then let the router point the traffic to the server? I have DHCP so I'm using DynDNS's service to forward the traffic to my IP. – Niklas Sep 8 '11 at 6:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.