Report this

What is the reason for this report?

Issue with virtual hosts on centos

Posted on August 14, 2013

I successfully setup virtual hosts on my droplet with CentOS 6.4 x32 I was following this tutorial. https://www.digitalocean.com/community/articles/how-to-set-up-apache-virtual-hosts-on-centos-6

Everything is good except, some issues.

  1. If I setup virtual hosts, my default landing page is changed and pointing to one of my domain location. I want it to be some specific page or default CentOS setup page. This http://i.imgur.com/NLSJR.png After setting up virtual hosts, my default page is one of my domains page which I do not want.

  2. www.domain.com and domain.com are working fine and pointing to same location/page. But if I type a.domain.com or random.domain.com, it still points to my that location which I do not want. I want it to give error. I assume this random subdomains are pointing to main domain because I added wildcard entry *.domain.com as ServerAlias in httpd.conf. But if I do not add this wildcard then random subdomains points to one of my different domain.

Any ideas on these issues.



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

I have created 4 virtual hosts right now. And they do have all different DocumentRoot. Here is virtual host entry. <br> <br><VirtualHost *:80> <br> ServerAdmin webmaster@mydomain.com <br> DocumentRoot /home/myuser/mydomain.com/public <br> ServerName www.mydomain.com <br> ServerAlias mydomain.com <br> DirectoryIndex index.html index.php <br> ErrorLog /home/myuser/mydomain.com/log/error.log <br> CustomLog /home/myuser/mydomain.com/log/access.log combined <br></VirtualHost> <br>

<VirtualHost *:80> <br> ServerAdmin webmaster@mydomain.com <br> DocumentRoot /home/myuser/mydomain.com/public <br> ServerName www.mydomain.com <br> ServerAlias mydomain.com <br> DirectoryIndex index.html index.php <br> ErrorLog /home/myuser/mydomain.com/log/error.log <br> CustomLog /home/myuser/mydomain.com/log/access.log combined <br></VirtualHost> <br>

How many virtual hosts did you create? Do they all have different <code>DocumentRoot</code>s? Where exactly did you declare the wildcard entry? In a specific vhost?

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.