Change Apache2 ports.conf in order to localhost interface to listen to port 80

20,965

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

Share:
20,965
rfc1484
Author by

rfc1484

Updated on November 15, 2020

Comments

  • rfc1484
    rfc1484 over 3 years

    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?