Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I activated several virtual servers on my Apache, and since then, all the domains I use are directed to the directory of a single one of them (in this case, /var/www/mydomain.com).
This is the config section:
Code:
<VirtualHost *>
DocumentRoot "/var/www/mydomain.com"
ServerName mydomain.com
<Directory "/var/www/mydomain.com">
allow from all
Options +Indexes
</Directory>
</VirtualHost>
<VirtualHost *>
DocumentRoot "/var/www/mydomain2.com"
ServerName mydomain2.com
<Directory "/var/www/mydomain2.com">
allow from all
Options +Indexes
</Directory>
</VirtualHost>
<VirtualHost *>
DocumentRoot "/var/www/mydomain.com"
ServerName www.mydomain.com
<Directory "/var/www/mydomain.com">
allow from all
Options +Indexes
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/mydomain2.com
ServerName www.mydomain2.com
<Directory "/var/www/mydomain2.com">
allow from all
Options +Indexes
</Directory>
LogLevel debug
</VirtualHost>
But on my sites, I have the document root, separate from the site root:
DocumentRoot "/var/www/mydomain2.com/html"
SetEnv SITE_ROOT /var/www/mydomain2.com
SetEnv SITE_HTMLROOT /var/www/mydomain2.com/html
Thanks guys. I missed it at first, because in my config file, that directive was followed by *:80, so I didn't think it was related.
One thing left now. If I go to the server by its IP address (no domain name), it goes to the mydomain.com directory (the first virtual server), but I would like it to go to the /var/www/html directory, just like the https does. Where should I define that? Should I create another virtual server with any/any settings?
Define the site correctly. The first virtual site should have DocumentRoot defined the way you want it. Personally I wouldn't have all the sites under /var/www , I would put them in separate directories :
/home/site1/www/html/
/home/site2/www/html/
etc, etc.
Sites can be anywhere, you just specify the directory in the httpd.conf
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.