Problem with root and virtual host

  • Posted July 4, 2013

Hi, I have installed lamp stack on centos for my Now I have created virtualhost for At first domain1 was pointing to the starting page of "apache ", but after I created virtual host for and created a new file index.php, is pointing to the same index.php for

Please help how to get the “apache page” or how to proceed so that both the domains are pointing to their respective root directory.

Thanks in advance


Submit an 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.

Hi hypertextsol! <br> <br>you try to place namesarver directives in first position. Example: <br> <br><VirtualHost *:80> <br> ServerName <br> ServerAlias <br> ServerAdmin <br> DocumentRoot /var/www/ <br></VirtualHost> <br> <br><VirtualHost *:80> <br> ServerName <br> ServerAlias <br> ServerAdmin <br> DocumentRoot /var/www/ <br></VirtualHost> <br> <br>I had the same problem and this solved it

“<strong>what should be the root directory of the …</strong>” <br> <br>It’s a matter of personal preference. It’s okay to have’s root directory be <pre>/var/www/</pre>; or, if you want to be consistent across all domains, have the root directory be <pre>/var/www/</pre> <br> <br>The key is to make sure that whatever root directory you choose is accurately stated in each virtual hosts’ file in the <pre>/sites-enabled</pre> folder

what should be the root directory of the to which I have assigned the droplet – i.e. I have assigned to the droplet and is the addon domain. <br>As I have created the directory structure as “/var/www/” but I never created the same for

@hypertextsol, <br> <br>Have you checked out this article?: <a href=“”>How to Set Up Apache Virtual Hosts on CentOS 6</a>

I think I have messed up everything - should try with a new installation nothing is working good. <br>Thanks a lot for your help <br>@kamal

I see only one VirtualHost ( Are you sure you saved the file after adding the new one? <br> <br>You also have “ServerName” twice in your VirtualHost, delete one of them.

I just created the entry for virtualhost in " /etc/httpd/conf/httpd.conf" as mentioned in the article <br> <br>then I create a file in /var/www/… after that both the domain started pointing to this file

but after I created virtual host for <br> <br>Where did you create that file?

output of ls /etc/httpd/conf.d = " README php.conf phpMyAdmin.conf phpMyAdmin.conf.rpmsave welcome.conf"

Hmm. What’s the output of “ls /etc/httpd/conf.d”?