Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
10-05-2011, 10:10 PM #1
- Join Date
- Jan 2010
- Birmingham, MI
- Thanked 9 Times in 9 Posts
Problems with Virtual Hosts configuration in Ubuntu server
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 </VirtualHost>
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 \ </IfModule>
Last edited by JamesOxford; 10-05-2011 at 10:17 PM.
10-06-2011, 09:43 AM #2
- Join Date
- Jul 2011
- Thanked 13 Times in 13 Posts
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.