1

I have configured apache to listen on Port 80 & 8080 and have created 2 conf files for the sites.

Port 80

<VirtualHost *:80>
 DocumentRoot /local/Web

    AddHandler cgi-script cgi
     Alias /access /local/Web/

    <Directory "/local/Web">
      AllowOverride All
      Options +ExecCGI

      DirectoryIndex index.html
    </Directory>
</VirtualHost>

access to 127.0.0.1 loads the correct site from /local/Web

Port 8080

<VirtualHost *:8080>
 DocumentRoot /local/Sites

    AddHandler cgi-script cgi
        Alias /site1 /local/Sites/site1/
        Alias /site2 /local/Sites/site2/
        Alias /site3 /local/Sites/site3/

    <Directory "/local/Sites">
      AllowOverride All
      Options +ExecCGI

      DirectoryIndex index.html
    </Directory>
</VirtualHost>

accessing 127.0.0.1:8080 brings up Access Denied which is fine

accessing 127.0.0.1:8080/site1 loads the correct site from /local/Sites/site1

accessing 127.0.0.1:8080/site2 loads the correct site from /local/Sites/site2

accessing 127.0.0.1:8080/site3 loads the correct site from /local/Sites/site3

I can't access site1, site2, site3 from port 80 and I can't access /access from port 8080 - which is all as expected.

I'm now trying to add a new site to Port 80 using a new conf file. I want this to have it's own conf file as :

<VirtualHost *:80>
 DocumentRoot /local/Web

    AddHandler cgi-script cgi
    Alias /new /local/new

    <Directory "/local/Web">
      AllowOverride All
      Options +ExecCGI

      DirectoryIndex index.html
    </Directory>
</VirtualHost>

Yet when I try any access 127.0.0.1/new I get 'Object not found!' and nothing is shown in the apache error_log

Any idea how I get /new to work on port 80 ?

  • Why don't you add a new alias to your existing <VirtualHost *:80> config file? – Dmitry Grigoryev Oct 29 '15 at 11:48
  • The sites are from two different applications. So I may have one config file, the other or both... – MacMan Oct 30 '15 at 15:13
1

Apache does not know which config for VirtualHost *:80 should use. You have two ways how to fix it:

  1. Merge those two configs into one virtualhost
  2. Use ServerName and "hostname" URL for determining which VirtualHost should be used.
  • Thanks - can server name be 127.0.0.1/new ? – MacMan Oct 30 '15 at 15:13
  • Nope, server name must be "hostname" ie. new-localhost. You have to modify your hosts to map new-localhost to your server with apache – Ondra Sniper Flidr Oct 30 '15 at 17:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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