Apache 显示 PHP 代码而不是执行它

问题描述:

我最近一直在尝试在我的计算机上安装 PHP 和 Apache.几个小时后,它们被安装.我像大家说的那样修改了 httpd.conf 和 php.ini 文件.然后我创建了一个简单的 PHP 脚本:

I have recently been trying to install PHP and Apache on my computer. After many hours, they're installed. I have modified the httpd.conf and php.ini files like everyone says. I then created a simple PHP script:

<?php phpinfo(); ?>

但是当我尝试使用 http://127.0.0.1/phpinfo.php 运行它时,它只显示源代码而不是执行它.我使用的是 Apache 2、PHP 5 和 Windows Vista.

But when I try to run it with http://127.0.0.1/phpinfo.php it just shows the source code instead of executing it. I am using Apache 2, PHP 5 and Windows Vista.

编辑行:

PHP.INI:

short_open_tag = On

HTTPD.CONF

LoadModule php5_module "C:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
PHPIniDir "C:/php"

您必须启用 php!检查Apache 目录中的文件夹mods-enabled(默认:/etc/apache2/),看看是否找到名为php 的文件.我不记得扩展名,但我认为它是 .so.

You must enable php! Check the folder mods-enabled in the Apache directory (default: /etc/apache2/) to see if you find a file named php. I don't remember the extension but I think it's .so.

还要检查 /var/log/apache2/error.log 以查看是否还有其他错误.

Also check in /var/log/apache2/error.log to see if you have any other errors.