<html>
<head>
<title>asdf</title>
</head>
<body>
<p>asdasdfasdfasdf</p>
<? echo ("KLJHLKJHLKJHLKJHLKJ\n"); ?></body>
</head>
网页上无法显示“KLJHLKJHLKJHLKJHLKJ”

解决方案 »

  1.   

    这个文件的名字要写成以php为后缀的才可以正常运行,比如写成test.php,写成HTML的是不可以的吧
      

  2.   

    是php后缀的呀,上述文件名为first.php
    我打入http://127.0.0.1能够显示apache的默认网页,但是打入http://127.0.0/1fist.php却是一个空白网页,first.php防在apache2文件夹下的htdocs中,是我打的地址不对,还是我的配置有问题?
    我试过好多配置了,都显示不出来
      

  3.   

    按以下步骤检查:
    1、写一个php文件,命名为phpinfo.php
    内容是<?php phpinfo();?>,放在apache2文件夹下的htdocs中
    2、起一个cmd窗口,运行"php phpinfo.php",看看是不是有一大堆东西从屏幕滚过去。如果没有,请检查是否在path中设置了php的目录。
    3、检查windows目录中是否已经拷贝了一个php.ini
    4、检查此php.ini的访问权限是否有system用户,如果没有,加上。
      

  4.   

    to: makefool(装傻) 
    我试了一下,在htdocs路径下无法显示,在php5路径下有一大堆东西滚过。
    但是在浏览器下键入http://127.0.0.1/first.php或者http://localhost/first.php都不行
      

  5.   

    Apache配置PHP,最好不以CGI方式运行,有安全问题,推荐使用模块方式LoadModule php5_module "C:/php/php5apache2.dll"
    DirectoryIndex index.php
    AddType application/x-httpd-php .php
      

  6.   

    改成echo "KLJHLKJHLKJHLKJHLKJ\n";试试看
      

  7.   

    呵呵,不会是<? ?>的问题吧,建议用<?php ?>看看吧.
      

  8.   

    问题很清楚了,系统路径中没有设置php的路径“我的电脑”(右键)-》属性-》高级-》环境变量-》“系统变量”-》path-》把你的php路径加进去。
    比如“;c:\php5”
      

  9.   

    PHP5
    羡慕共享软件交流群:6797304
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    网普科技美国Linux主机 50/年起 支持PHP+Mysql+Cpanel
    http://bbs.netpu.net  "共享软件专区"
    http://www.netpu.net   共享作者首选美国主机
    共享软件交流群:6797304
    QQ:126818
      

  10.   

    to: makefool(装傻) 
    我加了环境变量了,可还是不行啊
      

  11.   

    还是“在htdocs路径下无法显示,在php5路径下有一大堆东西滚过。”吗?
    试试在htdocs下直接运行“php -v”,看看有相应的版本信息。没有的话,就还是要检查环境变量。
    有的话,再运行“php -m”,看看模块配置是否得当。不得当的话,到
    php.ini文件中去删。最后检查php.ini文件是否在windows目录中。没有的话,拷过去。
      

  12.   

    在在htdocs路径下可以显示了,用php -v也有相应的版本信息了,php -m有东西,但是看不懂
    在浏览器中键入127.0.0.1/first.php发现"是否要保存此文件?",还是无法在网页中显示
      

  13.   

    嗯,明白了。
    看看你的apache 的配置文件“httpd.conf”,一定是没有配置php的相关内容,是apache不能解析php的调用。
    关于如何配置,请参阅php5目录中的install.txt文件。
    节选出来:
     Installing PHP on Windows with Apache 1.3.x ------------------------------------------------------------
     ATTENTION: Apache 2 Users   At this time, support for Apache 2 is experimental.  It's
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    php开发者不建议在apache2中使用php。
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       highly recommended you use PHP with Apache 1.3.x and not
       Apache 2.  Documentation for installing Apache 2 on windows 
       can be seen here:      http://www.php.net/manual/en/install.apache2.php   With the basic difference being that when installing as a 
       module you'll use php5apache2.dll instead of php5apache.dll
       Both files are included within this release.
      ------------------------------------------------------------
      There are two ways to set up PHP to work with Apache 1.3.x
      on Windows. One is to use the CGI binary (php.exe),
      the other is to use the Apache module dll. In either case
      you need to stop the Apache server, and edit your
      httpd.conf or srm.conf to configure Apache to work with PHP.
      We'll refer to either of these files with httpd.conf in the
      text.  Although there can be a few variations of configuring PHP
      under Apache, these are simple enough to be used by the
      newcomer. Please consult the Apache Docs for further
      configuration directives.
      Installing PHP for Apache as module
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  Now that version 4.1 introduces a safer sapi module, we recommend
      that you configure PHP as a module in Apache.  To accomplish this, you have to load the php5apache.dll in your
      Apache httpd.conf.  !! NOTE !!
      Whereever you load php5apache.dll from, php5apache.dll also
      needs the php5ts.dll also included in the PHP distribution.
      php5apache.dll depends on php5ts.dll which is loaded as soon as
      Apache loads php5apache.dll. If php5ts.dll can't be found, you
      usually get an error like (also see the "Problems?" section at
      the end of the file):    Cannot load c:/php/php5apache.dll into server  So where does php5ts.dll has to be to be properly loaded ?
      php5ts.dll is searched in the following order:  1) in the directory where apache.exe is start from
      2) in the directory where php5apache.dll is loaded from
      3) in your %SYSTEMROOT%\System32, %SYSTEMROOT%\system and
         %SYSTEMROOT% directory.
         Note: %SYSTEMROOT%\System32 only applies to Windows NT/2000/XP)
      4) in your whole %PATH%  Note: What is %SYSTEMROOT% ? Depending on your Windows
            installation this may be for example c:\winnt or C:\windows  Usually you would just copy it over to %SYSTEMROOT%\System32.
      But if you want to have multiple PHP installations (for
      whatever reason) this is a bad idea. For this circumstance the
      safest thing is to let php5ts.dll reside in the same directory
      where php5apache.dll is loaded from (see point 2 above).
      After you've set up the file layout properly, you're ready to
      finally configure Apache to load the PHP module. Just add the
      following lines to your httpd.conf:   LoadModule php5_module c:/php/php5apache.dll
       AddModule mod_php5.c
       AddType application/x-httpd-php .php  Note: Especially newer versions of Apache do not need the
            AddModule directive anymore, your milage may vary.
      Where do I have to put the php.ini ?
       The php.ini files is only searched in two places:
       1) in your Apache installation directory (e.g. c:\apache\apache)
       2) in your %SYSTEMROOT% directory.
        Installing PHP for Apache as CGI binary
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  If you wish to install PHP as a CGI binary, read this first:    http://www.cert.org/advisories/CA-1996-11.html  and then if you are really sure, insert these lines to your conf file:    ScriptAlias /php/ "c:/php/"
       AddType application/x-httpd-php .php
       Action application/x-httpd-php "/php/php.exe"
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    这里是关于CGI方式的配置,不过我不建议使用CGI方式,而应使用module方式。  Note, we consider installing PHP like this suicidal.  As a further precaution, we recommend you change the "/php/"
      ScriptAlias to something more random, to prevent the binary being
      called directly, which is a security risk.  Remember when you have finished to restart the server, for example,
       NET STOP APACHE
      followed by
       NET START APACHE  To use the source code highlighting feature, add the following
      line to your apache httpd.conf file:    AddType application/x-httpd-php-source .phps  Note, this will only work when you install php as a sapi module.
      If you wish to use this feature with the cgi binary, create a new
      file, and use the show_source("path/to/original_file.php"); function.
      Forward or backslash in pathnames ?
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      On Win-Apache, path names can contain either forward- or backslashes.
      Example:    LoadModule php5_module C:\php\php5apache.dll  works as good as     LoadModule php5_module C:/php/php5apache.dll  You even can mix the slash-style:    LoadModule php5_module C:\php/php5apache.dll
      

  14.   

    终于配成功了,谢谢 makefool(装傻)