[SOLVED] Virtualhosts problem
When I try to access it with
Any idea why?
Here's the content of /etc/apache2/sites-available/example.com
<virtualhost *="">ServerAdmin admin@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/vhosts/example.com/htdocs
AddHandler fcgid-script .php
FCGIWrapper /usr/lib/cgi-bin/php5 .php
LogLevel warn
ErrorLog /var/www/vhosts/example.com/log/error.log
CustomLog /var/www/vhosts/example.com/log/access.log combined</virtualhost>
7 Replies
Here's the default file:````
NameVirtualHost *
DocumentRoot /var/www
<directory>Options Indexes FollowSymLinks MultiViews
AllowOverride all</directory>
<directory var="" www="">Options Indexes FollowSymLinks MultiViews
#Options -FollowSymLinks
AllowOverride all
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
# RedirectMatch ^/$ /apache2-default/</directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<directory "="" usr="" lib="" cgi-bin"="">AllowOverride all
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all</directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
Alias /doc/ "/usr/share/doc/"
<directory "="" usr="" share="" doc="">Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128</directory></virtualhost>
````
What should I change to make example.com (without www) work?
2) Do you have DNS A records for both "
3) Alternatively, remove the ServerAlias directive and create a second virtualhost setup for "example.com", with an .htaccess redirect to "
1) What else should I set it? I mean I have several domains there and should I set it to something that's not a domain? That would cause problems with spam blacklists because I send mail from these domains. Any suggestions?
2) Yes, I have them as they are automatically added by Linode's DNS manager when set as "master".
3) This seems like an ugly workaround, if there's an alternative I'd like to go with that.
–----
Now, I've changed my hostname to something that doesn't make sense, like "whatever.com". This solved all my problems, but this is surely not the way to go. What can I do?
Thanks for the help mjrich.
@dcelasun:
1) What else should I set it? I mean I have several domains there and should I set it to something that's not a domain? That would cause problems with spam blacklists because I send mail from these domains. Any suggestions?
The hostname needn't be related to mail – use mailname (or some derivative if more than one domain).
> 3) This seems like an ugly workaround, if there's an alternative I'd like to go with that.
Creating a second virtual host, redirecting to the first is the most reliable option (though I'd be interested if others have a more developed opinion). To paraphrase a faq at, using both the bare domain and the www version without redirects creates issues such as: NFS
* Noncanonical URLs for your site. It is desirable to have one URL for each page, for purposes of bookmarking, etc. Having multiple valid URLs for the same page makes your site less popular in rankings and for search engines.
Potentially less reliable. DNS CNAME records cannot be used in this situation. You can put in a couple of A records, but this is still not as effective for load balancing and fault tolerance as doing it the "right" way.
It becomes hopelessly confusing if you have (or might ever have) more than one web site under the domain.
See also
http://no-www.org> Now, I've changed my hostname to something that doesn't make sense, like "whatever.com".
From your example, it seems as if you're trying to use a FQDN as a hostname, but surely this isn't the case (?)
Glad to hear it's all working though
I'll also set an htaccess redirect for www, I now understand your points. Thanks for pointing them out!