2 Replies Latest reply on Mar 22, 2009 2:16 AM by Newsgroup_User

    Testing Server for PHP using Apache for two virtual hosts

    Level 7
      I am running a single copy of apache2 on win32 platform and using DW 8
      to manage two sites, jetCat and CADev... All going pretty well.
      BUT
      Case 1:::
      with DW set to use 'localhost' to test PHP pages from CADev site on the
      browser.

      and with the hosts in apache htppd.conf in this order:

      ServerName *:80
      NameVirtualHost *:80

      <VirtualHost *:80>
      ServerName jetcat.dyn-o-saur.com
      DocumentRoot "D:/WWW/Server/JetCat2009/"
      </VirtualHost>

      <VirtualHost *:80>
      ServerName creativeafternoon.simple-url.com
      DocumentRoot "D:/WWW/Server/CADev/"
      </VirtualHost>

      Listen 80

      #EOF

      SO, in the site "CADev" I am trying to "run" a simple PHP by using F12
      in DW and get this feedback:
      http://localhost/PHP/timetest.php is shown as the URL,
      and the browser displays:
      "Not Found
      The requested URL /PHP/timetest.php was not found on this server.
      Apache/2.0.59 (Win32) PHP/5.2.8 Server at jetcat.dyn-o-saur.com Port 80"

      So it would seem localhost is being used and not shared by the default
      server, which is JetCat because it is first in the list.
      However both CA simple url and JetCat url are being presented correctly
      by the DDNS hosts.


      CASE 2:::::
      with DW set to use localhost to serve CADev files on the browser (same
      as before and jetcat being defined in DW to not use localhost)

      ANYWAY, with the hosts in this order:

      ServerName *:80

      NameVirtualHost *:80

      <VirtualHost *:80>
      ServerName creativeafternoon.simple-url.com
      DocumentRoot "D:/WWW/Server/CADev/"
      </VirtualHost>

      <VirtualHost *:80>
      ServerName jetcat.dyn-o-saur.com
      DocumentRoot "D:/WWW/Server/JetCat2009/"
      </VirtualHost>

      Listen 80

      #EOF

      After restarting apache and editing the file timetest.php on the server
      path of creativeafternoon.simple-url.com

      We get this by pressing f12 in DW:
      http://localhost/PHP/timetest.php as an address

      And we get this message:
      This page was created at 04:56:08 pm on the computer running PHP.

      So PHP testing works with this arrangement - BUT STRANGELY however only
      the JetCat documents are being served on BOTH DDNS.

      Weird but surely not unfixable - any ideas?
      // jeremy <grin> i am a bit self taught....</grin>
        • 1. Re: Testing Server for PHP using Apache for two virtual hosts
          Level 7
          jeremy wrote:
          > ServerName *:80
          > NameVirtualHost *:80
          >
          > <VirtualHost *:80>
          > ServerName jetcat.dyn-o-saur.com
          > DocumentRoot "D:/WWW/Server/JetCat2009/"
          > </VirtualHost>
          >
          > <VirtualHost *:80>
          > ServerName creativeafternoon.simple-url.com
          > DocumentRoot "D:/WWW/Server/CADev/"
          > </VirtualHost>
          >
          > Listen 80

          This setup disables the main server root. You need to add another
          VirtualHost definition for localhost.

          ServerName *:80
          NameVirtualHost *:80

          <VirtualHost *:80>
          ServerName localhost
          DocumentRoot "C:/path/to/htdocs"
          </VirtualHost>

          <VirtualHost *:80>
          ServerName jetcat.dyn-o-saur.com
          DocumentRoot "D:/WWW/Server/JetCat2009/"
          </VirtualHost>

          <VirtualHost *:80>
          ServerName creativeafternoon.simple-url.com
          DocumentRoot "D:/WWW/Server/CADev/"
          </VirtualHost>

          Listen 80

          --
          David Powers
          Adobe Community Expert, Dreamweaver
          http://foundationphp.com
          • 2. Re: Testing Server for PHP using Apache for two virtual hosts
            Level 7
            David Powers said
            > This setup disables the main server root. You need to add another
            > VirtualHost definition for localhost.
            >
            > ServerName *:80
            > NameVirtualHost *:80
            >
            > <VirtualHost *:80>
            > ServerName localhost
            > DocumentRoot "C:/path/to/htdocs"
            > </VirtualHost>
            >
            > <VirtualHost *:80>
            > ServerName jetcat.dyn-o-saur.com
            > DocumentRoot "D:/WWW/Server/JetCat2009/"
            > </VirtualHost>
            >
            > <VirtualHost *:80>
            > ServerName creativeafternoon.simple-url.com
            > DocumentRoot "D:/WWW/Server/CADev/"
            > </VirtualHost>
            >
            > Listen 80
            >

            Thanks for your response David - it put me on the right track...

            ServerName *:80
            NameVirtualHost *:80

            <VirtualHost *:80>
            ServerName jetcat.dyn-o-saur.com
            DocumentRoot "D:/WWW/Server/JetCat2009/"
            </VirtualHost>

            <VirtualHost *:80>
            ServerName creativeafternoon.simple-url.com
            DocumentRoot "D:/WWW/Server/CADev/"
            </VirtualHost>

            <VirtualHost *:80>
            ServerName localhost
            DocumentRoot "D:/WWW/Server/CADev/"
            </VirtualHost>

            Jetcat is not in development (for now) so I have assigned localhost to
            the CADev docroot. Requests fall through jetcat and end up at the last
            virtualhost, which is localhost and is therefore available as a testing
            server for me in DW8. Not Bad! (not obvious either but now I see - I think.)
            thanks for your help.
            Jeremy