hi ,

I am new to PHP. installed php 5. whenI try to run very simple php 'hello world' the browser does not give any thing.

Sometime if i type http://127.0.0.1:80 it does not gives any. May be a blank page.

my ow is win 2000. Web server is apachi 2

nena

    Hi Nena

    Could be several things:

    1. Did you edit httpd.conf to run PHP?

    2. Did you edit httpd.conf to point to a directory in which it can expect your PHP files?

    3. Did you copy php.ini to c:\windows?

    4. Does http://localhost SOMETIMES work or not all? Your posting seems to suggest that it sometimes works. This means that it is working but that you are probably forgetting to start Apache. Most win32 installations in winNT systems (NT/2K/XP) install Apache so that it starts at boot - so you don't have to actually start it yourself. However, you'll find a controller in your systray which allows you to check the status and restart if necessary.
      Btw - some browsers (Netscape and Opera, I think) have a default setting which won't allow you to look at 127.0.0.1. I can't remember where the setting is, but you need to disable it first.

    5. Did you create your first PHP file using MS-Notepad? If you did, Notepad probably added .txt onto the end of the file without asking you. Three solutions: 1. Fix the file name in WinExplorer so that the ending is .php - Apache won't run it through PHP otherwise; 2. Insert files names in inverted commas when saving in Notepad; 3. Get a real text editor (JEdit is open source, free and available for win or Linux ... and it's good).

    HTH

    Norm

      Hi,

      Thanks for the prompt reply. Here is my comments

      1.Did you edit httpd.conf to run PHP?

      I edit it to listen the port. See below. Like this.
      Listen 9001
      #NameVirtualHost 127.0.0.1:9001

      <VirtualHost 127.0.0.1:9001>
      DocumentRoot "D:\me\Developments\Php\Study"
      </VirtualHost>

      Does this you mean to run PHP?

      I think for the bullet 2 same answer apply.

      1. Did you copy php.ini to c:\windows?
        I didn't do this. where is this php.ini can find?

      .4
      Ya it works some times. this is for only one folder. And it is mentioned above. this folder doesn't consist any php content. Simplae HTML files. When try to test PHP with another folder no results? To do this I configure the httpd.conf file too.

      5.
      No doubt. The extention is '*.php'.

      My Apachi is running well (I think). When ever I edit my 'httpd.conf' I restarted the Apachi. No errors found.

      Hope this clears some doubts I kept first.

      Nena

        Hi Nena

        You need to tell Apache to parse PHP files. Read this first.

        The lines you need to add to httpd.conf are:

         For PHP 4 do something like this:
        LoadModule php4_module "c:/php/php4apache2.dll"
        AddType application/x-httpd-php .php
        
        # For PHP 5 do something like this:
        LoadModule php5_module "c:/php/php5apache2.dll"
        AddType application/x-httpd-php .php
        
        # configure the path to php.ini
        PHPIniDir "C:/php"

        You need to rename php.ini-dist to php.ini and paste it into whichever directory you define in httpd.conf

        HTH

        Norm

          9 days later

          I'm having a similar problem, only i didn't try to set up virtual hosting. Only experimentation server on my own computer where i can use loopback to test: http://localhost/exp/fun.php

          The problem is: php code is not parsed as code, but transfered directly as a Processing instruction, just like <?xml ?>, for example. That's why nothing is visible on the browser.

          Some installation details:
          Apache 2.0.53 from windows installer.
          PHP 5.0.3 or 4.3.10 from zipped binaries (both had the same problem).

          I did everything the manual said. PHP is extracted to C:\php. The Apache installer extracted everything to C:\Program Files\Apache Group\apache2.

          I added to httpd.conf AddType, LoadModule and PHPIniDir just as the manual said. Also that php4ts.dll was copied to apache2\bin directory.

          The problem still existed after adding c:\php to PATH, copying php4apache2.dll to Windows\system32 directory and php.ini to Windows directory.

          Also, i'm on a home network. Two computers with one internet connection and the regular windows Internet Connection Sharing. I don't know if it has anything to do with it, because the first apache Test Page can be seen. Only php code between <?php and ?> isn't being parsed.

            Now i see that only http://localhost/index.php is being parsed. everything else, including other php files in the doc-root and other index.php in different subfolders are not parsed.

            Anyone has any clue about this?

              Now all php files withing the document root directory (htdocs) are parsed, but non in the subdirectories (htdocs/sub). And instead of seeing nothing in the browser and the php code in the "view source", I get this output:

              &#255;&#254;<?php echo 'lalala'; ?>

              with those out of place letters. Each character encoding (chosen in the browser) shows it as something else, like a question mark '?'.

              How do i tell apache or php to parse files in all subdirectories? Just two weeks ago i didn't have to add any directive for it to work.

              Thank you all.

                Write a Reply...