apache default virtual host
Hello,
how do I define the default virtual host to be served on port 80? I have different configuration files in /etc/httpd/conf.d/ that look more or less like this: <VirtualHost *:80> ServerName mydomain.com ServerAlias www.mydomain.com DirectoryIndex index.php index.html index.htm ServerSignature email DocumentRoot /var/www/mydomain.com/ </Virtualhost> plus I have the namevirtualhost:80 in httpd.conf for some reason if I connect to port 80 using the IP address or an alias not defined anywhere in apache config, the first domain configured (first alphabetically a-to-z) answers the call. Is there any way to overwride this and set a default site? Basically I'd like to answer with the right configuration if a precise site pre-configured is called on port 80, but if not I would like to redirect to a "default site" I hope I've explained myself :-p Thanks for reading rs232 |
everything you have is already correct, what you need
is just add this on the top of your <VirtualHost> as below --------------------- Code:
namevirtualhost:80 |
I did try this before but no luck.
basically every virtual server has a file into conf.d with a generic <VirtualHost *:80> ServerName mydomain.com ServerAlias www.mydomain.com DirectoryIndex index.php index.html index.htm ServerSignature email DocumentRoot /var/www/mydomain.com/ </Virtualhost> Where the main virtual host has its own file still in conf.d in the format: <VirtualHost *:80> ServerName domain.serverhostname.com DocumentRoot /var/www/html </VirtualHost> I'm wondering about 2 things now. 1) shell I add the <VirtualHost *:80> ServerName domain.serverhostname.com DocumentRoot /var/www/html </VirtualHost> inside http.conf instead then conf.d/myfile? 2) the current default virtual server (which I don't want to be the default) has both ServerName directive AND file name into conf.d starting with a "d" where the one I want to be the default has a filename (no ServerName used) starting with an "m" Is Apache giving priority to the config file name or to the ServerName command? Cheers |
normaly i didnt touch anything in httpd.conf
what i did is only create virtual.conf inside conf.d/ here is mine just for example Code:
[root@ns1 ~]# cat /etc/httpd/conf.d/virtual.conf one more thing if you check my domain its still might not get as you need because only for development mode but its worked that way |
Ok I've found the solution. What you're saying is correct but I'll add more details for reference:
My point is that I have 1 different file for each virtual server into conf.d By default apache loads these files in order alphabetically from a to z renaming the default one so that it becomes the first in the list does the job. ls -la to verify So... all I had to do was to rename mxxxxxxx into amxxxxxx this way I force apache to read it before the others. sorted :-) |
glad you found it, in my conf.d
i have few .conf file create by hand , doesnt matter read which one first but for sure apache will read and use all .conf file inside that conf.d folder cheers |
All times are GMT -5. The time now is 07:44 AM. |