XAMPP:如何为 PHP 配置 Apache

Posted

技术标签:

【中文标题】XAMPP:如何为 PHP 配置 Apache【英文标题】:XAMPP: how to configure Apache for PHP 【发布时间】:2011-04-26 04:22:27 【问题描述】:

我的 XAMPP 没有读取我的 php。可能是我的 Apache 配置有问题。我的 PHP 书建议我打开 httpd 配置文件并添加以下几行:

LoadModule php5_module c:/php/php5apache2_2.dll  
PHPIniDir "c:/php/"  
AddType application/x-httpd-php .php

我这样做了,但是当我回到控制面板重新打开 Apache 时,我无法通过它获得运行标志。我认为这是因为我的 PHP 认为我没有使用 XAMPP。我尝试了以下方法:

LoadModule php5_module c:/xampp/php/php5apache2_2.dll  
PHPIniDir "c:/xampp/php/"  
AddType application/x-httpd-php .php

但是问题并没有解决(PHP 还是不行,我在控制面板里看不到 Apache 的运行标志)。我该怎么办?如果重要的话,我使用的是 Windows 7。

卸载XAMPP并删除目录后,我遇到了同样的问题。这是最新的错误日志:

[Fri Oct 15 19:44:00 2010] [notice] Digest: generating secret for digest authentication ...  
[Fri Oct 15 19:44:00 2010] [notice] Digest: done  
[Fri Oct 15 19:44:00 2010] [notice] Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14   OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations  
[Fri Oct 15 19:44:00 2010] [notice] Server built: Nov 11 2009 14:29:03  
[Fri Oct 15 19:44:00 2010] [notice] Parent: Created child process 912  
[Fri Oct 15 19:44:03 2010] [notice] Digest: generating secret for digest authentication ...  
[Fri Oct 15 19:44:03 2010] [notice] Digest: done  
[Fri Oct 15 19:44:04 2010] [notice] Child 912: Child process is running  
[Fri Oct 15 19:44:04 2010] [notice] Child 912: Acquired the start mutex.  
[Fri Oct 15 19:44:04 2010] [notice] Child 912: Starting 150 worker threads.  
[Fri Oct 15 19:44:04 2010] [notice] Child 912: Starting thread to listen on port 443.  
[Fri Oct 15 19:44:04 2010] [notice] Child 912: Starting thread to listen on port 80.  

【问题讨论】:

PHP 书不认为我在使用 XAMPP,我应该说。 Windows 上的目录分隔符不是“\”吗?你为什么用斜杠,你习惯linux吗?如果是,为什么不在 Virtualbox 上的 debian 上安装您的服务器? 我把所有的'/'都改成了'\'。还是不行。我从未使用过 Linux。 你应该检查apache error.log,应该在apache安装的/log forlder中 我做到了。然后我卸载了程序并删除了目录。重新安装,遇到同样的问题。这是错误日志: 【参考方案1】:

确保您没有运行另一个 XAMPP 副本或任何其他服务器,这可能会导致冲突。

确保 Apache 默认使用的端口 80 未被其他应用程序(例如 Skype 等)使用。

正如 colum 所说,xammp 应该可以开箱即用,而 php 已经可以工作了。

创建一个像这样的测试 php 页面并将其放在 htdocs 文件夹中

<?php
echo "PHP works";
?>

如果你可以进入管理页面,有一个链接 php.info。看看它是否有效。

【讨论】:

【参考方案2】:

如果您使用的是从他们的网站下载的 XAMPP,那么 PHP 应该可以直接使用。您可以随时尝试从源代码伪造再次下载它。您可以随时在错误日志中查找错误。

【讨论】:

以上是关于XAMPP:如何为 PHP 配置 Apache的主要内容,如果未能解决你的问题,请参考以下文章

如何为 xampp 的 php 7.3 添加 GD 支持?

有多个 xampp 版本时如何为作曲家设置 php 版本?

如何为开发环境配置 vhosts/apache 子域?

网站环境apache + php + mysql 的XAMPP,如何实现一个服务器上配置多个网站?

如何为 GET 请求正确配置 Apache 重写规则?

如何在 XAMPP 中配置 php 邮件