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:

<VirtualHost example.com>
   ServerAdmin webmaster@localhost
   ServerAlias www.edunder.se
   DocumentRoot /var/www/sites/example
   CustomLog /var/log/apache2/www.example.com-access.log 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 example.com www.example.com localhost.localdomain localhost example2.com www.example2.com localhost.localdomain localhost example3.com www.example3.com

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

  • 1
    You might also ask at serverfault.com, a StackExchange for setting up and maintaining servers and systems. – Kris Harper Sep 6 '11 at 19:48
  • 2
    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:

<VirtualHost example.com:80>

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.

  • 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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