Problem with root and virtual host

July 4, 2013 5.2k views
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
19 Answers
Please post your directory structure and pastebin your apache virtualhost configs.
Sorry to say ...but I am a total newbie.. how to post my directory structure? and how to I copy the contents of virtualhost configs. from vi editor
You can run the following command to paste a file to

cat /etc/apache2/sites-enabled/filename | curl -F 'sprunge=
(Make sure you replace "filename" with the actual virtualhost file name).
Hi, my link for vhost is here --
Thanks for your help
What's the output of "ls /etc/apache2/sites-enabled"?
ls: cannot access /etc/apache2/sites-enabled: No such file or directory - there is an error message for this command
the above virtualhost file content has been taken from /etc/httpd/conf/httpd.conf
Sorry, "ls /etc/httpd/sites-enabled"
There is no "sites-enabled" directory in httpd.
the structure of httpd are :"conf conf.d logs modules run" only
Hmm. What's the output of "ls /etc/httpd/conf.d"?
output of ls /etc/httpd/conf.d = " README php.conf phpMyAdmin.conf phpMyAdmin.conf.rpmsave welcome.conf"
> but after I created virtual host for

Where did you create that file?
I just created the entry for virtualhost in " /etc/httpd/conf/httpd.conf" as mentioned in the article

then I create a file in /var/www/ after that both the domain started pointing to this file
I see only one VirtualHost ( Are you sure you saved the file after adding the new one?

You also have "ServerName" twice in your VirtualHost, delete one of them.
I think I have messed up everything - should try with a new installation nothing is working good.
Thanks a lot for your help

Have you checked out this article?: How to Set Up Apache Virtual Hosts on CentOS 6
by Etel Sverdlov
This tutorial shows you how to set up a new directory, how to grant the correct permissions, how to add content to a new page, how to turn on virtual hosting, and how to, if needed, set up local hosts. Virtual Hosts are used to run more than one domain off of a single IP address and allows you to run multiple sites off of a single DigitalOcean droplet. This tutorial describes how to set up virtual hosts with Apache on Centos
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.
As I have created the directory structure as "/var/www/" but I never created the same for
"what should be the root directory of the ..."

It's a matter of personal preference. It's okay to have's root directory be
; or, if you want to be consistent across all domains, have the root directory be

The key is to make sure that whatever root directory you choose is accurately stated in each virtual hosts' file in the
Hi hypertextsol!

you try to place namesarver directives in first position. Example:

DocumentRoot /var/www/

DocumentRoot /var/www/

I had the same problem and this solved it
Have another answer? Share your knowledge.