0

It isn't critical that I get this working with a named host locally, as the main thing I needed was external network access (which I have already set up with port forwarding), but I'd still like to know why I can't access a VirtualHost with my defined ServerName.

I am working on a Raspberry Pi (Raspbian, which is Debian-based), but I have encountered the same problem on Ubuntu 18 on a VMWare VM, both on numerous OS and Apache installations.

In my Apache.conf I have added:

ServerName localhost   
NameVirtualHost *:8010

In my virtualhost.conf I have:

<VirtualHost *:8010>
    ServerAdmin admin@example.com
    DocumentRoot /var/www/html/MySite/public
    ServerName www.think.com
    ServerAlias www.think.com
    DirectoryIndex index.php

    ErrorLog /var/log/apache2/concrete5-error_log
    CustomLog /var/log/apache2/concrete5-access_log common
</VirtualHost>

(I have tried with and without a ServerAlias)

In my ports.conf I have added:

Listen 8010

And finally in my hosts I have:

127.0.0.1   localhost
::1     localhost ip6-localhost ip6-loopback
ff02::1     ip6-allnodes
ff02::2     ip6-allrouters

127.0.1.1       raspberrypi
127.0.0.3   www.think.com
127.0.0.2   gci.example.com

I can access my site through http://localhost:8010/ without issue, however http://www.think.com will always redirect to the Apache2 default page no matter what I do. Even if I follow exactly the Ubuntu tutorial I cannot get a named site working (https://ubuntu.com/tutorials/install-and-configure-apache#1-overview).

I have also disable the default site, tried with the default site on, both with the same result above.

Any help is appreciated!

edit: updated names to make question clearer

1 Answers1

0

You need to specify the port number if it isn't the default 80.

http://www.think.com:8010/

The alternative would be to have Apache listen on port 80. But, according to your description, Apache is already listening on that port. Why not add your virtualhost to that Apache, with a

<VirtualHost *:80>

See Name Based VirtualHost

Gerard H. Pille
  • 2,469
  • 1
  • 12
  • 10