XAMPP 在 Windows 上的 PHP 运行速度太慢了 100 倍 [英] PHP on Windows with XAMPP running 100 times too slow

查看:27
本文介绍了XAMPP 在 Windows 上的 PHP 运行速度太慢了 100 倍的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PHP 在我的 Windows 桌面上运行如此缓慢,以至于 phpMyAdmin 需要几分钟才能打开一个数据库.下面是运行一个简单的PHP测试程序的时间对比:

PHP runs so slowly on my Windows desktop that phpMyAdmin takes minutes to open a database. Here’s a comparison of the time to run a simple PHP test program:

  • 运行 XAMPP 的 Windows 8.1 机器:3597 毫秒
  • iPage 共享主机:65 毫秒
  • A2Hosting 共享主机:26 毫秒

这是测试程序……

<?php
$rStartTime = microtime(true);
$countTo = 100000;
$a = 0;
//$countTo = $countTo * 100;
for ($x = 0; $x <= $countTo; $x++) {
    $a = sqrt(pow($x, 2));
}
$rMs = floor((microtime(true) - $rStartTime) * 1000);
echo 'timer done, countTo=' . $a . ' ms=' . $rMs;

测试程序在没有调试的情况下运行,通过输入http://localhost/timer.php"进入火狐.

The test program is run without debugging, by entering "http://localhost/timer.php" into Firefox.

本地机器通常非常快.它正在运行……

The local machine is normally blazing fast. It’s running…

  • Windows 8.1
  • XAMPP 1.8.3(控制面板 v3.2.1)
  • Apache 2.4.4(最新是 2.4.20)
  • PHP 5.5.3
  • 反恶意软件 = Windows Defender
  • IDE = PHPStorm 10.0.2

是什么让 PHP 运行如此缓慢?

What's making PHP run so slowly?

推荐答案

我发现问题出在xamppphpphp.ini中的Xdebug.以下是尝试在网络上找到的许多解决方案的结果:

I found the problem was Xdebug in xamppphpphp.ini. Here're the results of trying many solutions found around the web:

以管理员身份运行 XAMPP 并重启服务器:3617 ms

Run XAMPP as adminisrator and restart server: 3617 ms

在 xampp/apache/conf/httpd.conf 中,将 localhost 替换为 127.0.0.1 并重新启动服务器:3639 ms

In xampp/apache/conf/httpd.conf, replace localhost with 127.0.0.1 and restart server: 3639 ms

在 Windows/System32/drivers/etc/hosts 中,添加127.0.0.1 127.0.0.1" &127.0.0.1 localhost"并重新启动 Windows:3960 ms

In Windows/System32/drivers/etc/hosts, add "127.0.0.1 127.0.0.1" & "127.0.0.1 localhost" and restart Windows: 3960 ms

在 Windows/System32/drivers/etc/hosts 中,取消注释127.0.0.1 localhost"并重新启动 Windows:3659 ms

In Windows/System32/drivers/etc/hosts, un-comment "127.0.0.1 localhost" and restart Windows: 3659 ms

在 php.ini 中,取消注释 zend_extension = "C:xamppphpextphp_eaccelerator_ts.dll" 并重启服务器:3643 ms

In php.ini, uncomment zend_extension = "C:xamppphpextphp_eaccelerator_ts.dll" and restart server: 3643 ms

在 php.ini 中,设置 xdebug.remote_enable=0:3598 毫秒

In php.ini, set xdebug.remote_enable=0: 3598 ms

在 php.ini 中,设置 remote_host="localhost": 3593 ms

In php.ini, set remote_host="localhost": 3593 ms

在 php.ini 中,设置 xdebug.profiler_enable=0:249 ms

In php.ini, set xdebug.profiler_enable=0: 249 ms

在 php.ini 中,注释掉所有 Xdebug 语句:27 ms - 成功!

In php.ini, comment out all Xdebug statements: 27 ms - Success!

可悲的是,我犯了错误,需要 Xdebug :-(

The sad part is, I make mistakes and need Xdebug :-(

这篇关于XAMPP 在 Windows 上的 PHP 运行速度太慢了 100 倍的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆