Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2010
    Location
    Birmingham, MI
    Posts
    98
    Thanks
    3
    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
    Code:
    <VirtualHost *:80>
    ServerName mydomain.com
    DocumentRoot /foo/bar/www
    </VirtualHost>
    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.

    Code:
    <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>
    Help with any of these problems is greatly appreciated.
    Last edited by JamesOxford; 10-05-2011 at 10:17 PM.

  • #2
    New Coder
    Join Date
    Jul 2011
    Posts
    67
    Thanks
    0
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •