View Full Version : Problems with Virtual Hosts configuration in Ubuntu server

10-05-2011, 10:10 PM
So I am in the process of moving everything I have from a windows based xampp installation to an LAMP stack in Ubuntu Server. Having not used Linux before, there was already a bit of a learning curve, but now I am having all kinds of problems with the apache configuration. First, I am having problems setting a virtual host to listen to every request on port 80

<VirtualHost *:80>
ServerName mydomain.com
DocumentRoot /foo/bar/www

This keeps throwing an error that apache cannot bind to a socket, or no sockets available. So I got this solved, but I am not entirely happy with the solution, and then I had another problem. I have a couple of domains where admin.mydomain.com should bring up a seperate document root than a request to mydomain.com. I used to just set the admin address's up on a separate virtual host with no problem. I can't get this to work now, and I am not sure what is different in my apache configuration. I am thinking about setting a regex expression to look for admin requests before the domain, and doing a re-direct. Is this my best option, or does anyone have another idea about what I might be doing wrong?

Finally, the last problem I am having is with the DirectoryIndex directive. In directories where there were both html and php indexes, my old server used to serve php files first. The DirectoryIndex section is set up identical to the windows installation, but now apache brings up the html files first. Does anyone know the solution to this? Apache doesn't seem to like those line breaks either, so I got rid of them in the Linux install.

<IfModule dir_module>
DirectoryIndex main.php main.html main.htm main.asp main.cgi main.shtml \
index.php index.pl index.cgi index.asp index.shtml index.html index.htm \
default.php default.pl default.cgi default.asp default.shtml default.html default.htm \
home.php home.pl home.cgi home.asp home.shtml home.html home.htm \


Help with any of these problems is greatly appreciated.

10-06-2011, 09:43 AM
The virtual host that you have posted will only likely get entered if the domain is mydomain.com, the only reason I can think of that this would behave any different to what you might be used to with xampp, is that Ubuntu generally has a default VirtualHost file (which you will see in sites-available). This is the one that will capture any request that doesn't have a domin that matches the ServerName / ServerAlias field of any other enabled VirtualHost.

Setting up admin.mydomain.com to point at a different document root, should just be a case of creating another VirtualHost file that has a ServerName of admin.mydomain.com, the convention in Ubuntu is to create a new file in the sites-available directory for each virtual host, then you can use a2ensite name-of-file to enable that virtual host.

With regards to the DirectoryIndex not working, I can only assume that overriding them in disabled, you will need to check your http.conf (or apache2.conf) files to check out what the default values are.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum