-1

I have a server with IP 1.2.3.4 and I want the domain www.something.com to load website from /var/www/html/something/

I've tried to configure them as follows:

NameVirtualHost 1.2.3.4:80

<VirtualHost 1.2.3.4:80>

ServerName www.something.com
ServerAdmin emai@email.com
DocumentRoot /var/www/html/something/
ErrorLog logs/something-error_log
CustomLog logs/something-access_log common
</VirtualHost>

I've reloaded apache, but when accesing the domain, it only shows the root of the server /var/www/html/

Any idea what is wrong?

1 Answers1

0

A common mistake is to set the IP address in VirtualHost and NameVirtualHost without good reason.

Instead, your config should read:

NameVirtualHost *:80

<VirtualHost *:80>
  ServerName www.something.com
  ServerAdmin emai@email.com
  DocumentRoot /var/www/html/something/
  ErrorLog logs/something-error_log
  CustomLog logs/something-access_log common
</VirtualHost>
Alastair McCormack
  • 2,184
  • 1
  • 15
  • 22
  • I've tried this method, but then 1.2.3.4 points to /var/html/something/ also! –  Oct 26 '12 at 10:18
  • If you start using NameVirtualHosting then you should stop using IP addresses. To work around this, add another VirtualHost with no ServerName definition to the bottom if your httpd.conf. – Alastair McCormack Oct 26 '12 at 10:22
  • 1
    I've just found this: http://wiki.apache.org/httpd/CommonMisconfigurations that you might find useful – Alastair McCormack Oct 26 '12 at 10:24