Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
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.
For some reason, I have to set up two virtual hosts for each domain, since www.example.com and example.com don't work properly unless I setup both. Is there a way around this?
The default server is set to serve from /var/www/html, and all the virtual hosts are under /home/vhosts. Now, when I enter the server's IP directly, or a domain name that's not configured, I end up at the jmoschetti45.com page, not the one I'm looking for in /var/www/html. Any ideas?
Here's what I have in httpd.conf:
Quote:
<VirtualHost jmoschetti45.com:80>
DocumentRoot /home/vhosts/mcomp
ServerName jmoschetti45.com
<Directory "/home/vhosts/mcomp">
allow from all
Options +Indexes
</Directory>
ServerAlias *.jmoschetti45.com
</VirtualHost>
<VirtualHost lynchsex.com:80>
DocumentRoot /home/vhosts/lynchsex
ServerName lynchsex.com
<Directory "/home/vhosts/lynchsex">
allow from all
Options +Indexes
</Directory>
ServerAlias *.lynchsex.com
</VirtualHost>
<VirtualHost radio276.com:80>
DocumentRoot /home/vhosts/radio276
ServerName radio276.com
<Directory "/var/www/html">
allow from all
Options +Indexes
</Directory>
ServerAlias www.radio276.com
</VirtualHost>
<VirtualHost jmoschetti45.de:80>
DocumentRoot /home/vhosts/mcomp
ServerName jmoschetti45.de
<Directory "/home/vhosts/mcomp">
allow from all
Options +Indexes
</Directory>
ServerAlias www.jmoschetti45.de
</VirtualHost>
<VirtualHost marquettedems.org:80>
DocumentRoot "/home/vhosts/marquettedems"
ServerName marquettedems.org
<Directory "/home/vhosts/marquettedems">
allow from all
Options +Indexes
</Directory>
ServerAlias *.marquettedems.org
</VirtualHost>
when I enter the server's IP directly, or a domain name that's not configured, I end up at the moschetti45.com page
This is the normal behavior. If you give the ip address or a domain that points to that ip but it's not configured in vhosts, then apache shows the default site, which is the one defined by ServerName in the main server configuration in httpd.conf.
Quote:
<VirtualHost jmoschetti45.com:80>
Note that there is no need to write the domain name inside the <VirtualHost> tag. Just use:
It's going to jmoschetti45.com because it's the first vhost in the list of vhosts. You can put radio276.com first, to show this site when a client does a request by ip address.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.