3

At the moment I have this config in /etc/apache2/ports.conf:

NameVirtualHost *:80
Listen 80

All works fine, but I want to change it to:

NameVirtualHost 127.0.0.1:80
Listen 127.0.0.1:80

However after restarting apache, it displays the following error message:

[warn] NameVirtualHost 127.0.0.1:80 has no VirtualHosts

So I've updated the website VirtualHost file under /etc/apache2/sites-available/foo.com:

Original:

<VirtualHost *:80>
...
</VirtualHost>

Updated:

<VirtualHost 127.0.0.1:80>
...
</VirtualHost>

But after restarting apache, it shows the default apache2 index.html that is in /var/www instead of the project under /var/www/foo

This is the only enabled VirtualHost on the server.

Also here is my /etc/hosts file:

127.0.0.1   localhost
127.0.1.1   debian
<publicIP>  <foo.com> <serverhostname>

The host OS is Debian 7.

Any suggestions?

3 Answers 3

1

Have you symlinked the /etc/apache2/sites-available/foo.com to /etc/apache2/sites-enabled/000-foo.com.

The default apache configuration only reads virtual hosts from the sites-enabled directory and not sites available.

I am guessing that if you go to /etc/apache2/sites-enabled and type ls -la you will only see a configuration for default site and not your new site. If this is the case then symlink your foo.com into the sites enabled directory as follows ln -s ../sites-available/foo.com 001-foo.com

1
  • 9
    Shouldn't be a2ensite foo be a better solution?
    – Wolfer
    Oct 5, 2013 at 18:58
0

I don't think Listen 80 should have been changed to Listen 127.0.0.1:80. All other changes look ok.

-2
  • Uninstall apache2 service
  • Run update cmd
  • Reinstall apache2
  • Edit virtual host

This worked for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.