看到源码是因为你的apache不能解析php代码。
修改apache/conf/httpd.conf,添加下面的内容:    ScriptAlias /php/ "E:/php/" //你本机的php的目录
    AddType application/x-httpd-php .php 
    AddType application/x-httpd-php .php3 
    AddType application/x-httpd-php .php4 
    AddType application/x-httpd-php .phtml 
    Action application/x-httpd-php "/php/php.exe" 至于文件存放目录,如果你不想放在htdocs下,只要把apache/conf/httpd.conf中的DocumentRoot改成你放php文件的目录即可。如:
DocumentRoot "E:/webroot"关于虚拟目录的设置,可以参考apache/conf/httpd.conf中的设置,照样改一下就可以了。如下:#<VirtualHost *>
#    ServerAdmin [email protected]
#    DocumentRoot /www/docs/dummy-host.example.com
#    ServerName dummy-host.example.com
#    ErrorLog logs/dummy-host.example.com-error_log
#    CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>配置好后将前面的注释符号(#)删除就可以了。不过你的情况应该还不需要使用虚拟目录。

解决方案 »

  1.   

    我按你的方法加了上面的语句后,最后页面显示变成这样了。Internal Server Error
    The server encountered an internal error or misconfiguration and was unable to complete your request.Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.More information about this error may be available in the server error log.
    --------------------------------------------------------------------------------Apache/2.0.43 Server at localhost Port 80
      

  2.   

    你的网页扩展名是什么?是.PHP还是.php3
    建议使用Apache 1.3.2x
      

  3.   

    我写的是PHP为后缀名。
    我用的是apache_2.0.43-win32-x86-no_ssl.exe,不好吗?哪里有Apache 1.3.2x下载?
      

  4.   

    到http://www.skcn.com下载1.3.27。新的版本好象要装PGP和MD5包,这个2.0安装版不是exe的,是MSI文件。
      

  5.   

    http://www.apache.org/dist/httpd/apache_1.3.27-win32-src.zip
    win下建议使用apache 1.3.2x
      

  6.   

    在win下使用2.0的版本也是很好的. uGain你提供的好像是源码而不是安装程序.
      

  7.   

    在HTTPD。CONF最后加下面的看看可以不
    Alias /虚拟目录名称/ "G:/实际虚拟目录名称/"
    ScriptAlias /php/ "d:/PHP安装目录/"
    AddType application/x-httpd-php .php
    Action application/x-httpd-php "/php/php.exe"
      

  8.   

    一定是你配置的问题,和apache版本没有关系。上网找一下,有这方面的文章。