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 so far.
I have 3 sites in /etc/apache2/sites-available
which all look 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
</VirtualHost>
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:
127.0.0.1 localhost
127.0.1.1 Ubuntu.lan Ubuntu
127.0.0.1 localhost.localdomain localhost example.com www.example.com
127.0.0.1 localhost.localdomain localhost example2.com www.example2.com
127.0.0.1 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 How do I set up an Ubuntu server to be (securely) available from the internet? 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 set up a firewall as well :D
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:
And each virtual host should define a port:
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.