XAMPP 在 Windows 上运行的 PHP 速度太慢了 100 倍
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36754293/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP on Windows with XAMPP running 100 times too slow
提问by CaptureWiz
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:
PHP 在我的 Windows 桌面上运行非常缓慢,以至于 phpMyAdmin 需要几分钟才能打开一个数据库。下面是运行一个简单的 PHP 测试程序的时间对比:
- Windows 8.1 machine running XAMPP: 3597 ms
- iPage shared hosting: 65 ms
- A2Hosting shared hosting: 26 ms
- 运行 XAMPP 的 Windows 8.1 机器:3597 毫秒
- iPage 共享主机:65 毫秒
- A2Hosting 共享主机:26 毫秒
Here's the test program…
这是测试程序……
<?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;
The test program is run without debugging, by entering "http://localhost/timer.php" into Firefox.
测试程序无需调试即可运行,通过在 Firefox 中输入“ http://localhost/timer.php”。
The local machine is normally blazing fast. It's running…
本地机器通常非常快。它正在运行……
- Windows 8.1
- XAMPP 1.8.3 (control panel v3.2.1)
- Apache 2.4.4 (latest is 2.4.20)
- PHP 5.5.3
- Antimalware = Windows Defender
- IDE = PHPStorm 10.0.2
- 视窗 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
What's making PHP run so slowly?
是什么让 PHP 运行如此缓慢?
回答by CaptureWiz
I found the problem was Xdebugin xampp\php\php.ini. Here're the results of trying many solutions found around the web:
我发现问题是xampp\php\php.ini 中的Xdebug。以下是尝试在网上找到的许多解决方案的结果:
Run XAMPP as adminisratorand restart server: 3617 ms
以管理员身份运行 XAMPP并重新启动服务器: 3617 毫秒
In xampp/apache/conf/httpd.conf, replace localhost with 127.0.0.1 and restart server: 3639 ms
在 xampp/apache/conf/ httpd.conf 中,将 localhost 替换为 127.0.0.1 并重新启动服务器: 3639 毫秒
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 127.0.0.1”和“127.0.0.1 localhost”并重启Windows: 3960 ms
In Windows/System32/drivers/etc/hosts, un-comment “127.0.0.1 localhost” and restart Windows: 3659 ms
在 Windows/System32/drivers/etc/ hosts 中,取消注释“127.0.0.1 localhost”并重新启动 Windows: 3659 毫秒
In php.ini, uncomment zend_extension = "C:\xampp\php\ext\php_eaccelerator_ts.dll" and restart server: 3643 ms
在php.ini中,取消的zend_extension = “C:\ XAMPP \ PHP \分机\ PHP_ eAccelerator在_ts.dll”并重新启动服务器: 3643毫秒
In php.ini, set xdebug.remote_enable=0: 3598 ms
在 php.ini 中,设置 xdebug。远程启用=0: 3598 毫秒
In php.ini, set remote_host="localhost": 3593 ms
在 php.ini 中,设置 remote_host=" localhost": 3593 ms
In php.ini, set xdebug.profiler_enable=0: 249 ms
在 php.ini 中,设置 xdebug。profiler_enable=0: 249 毫秒
In php.ini, comment out all Xdebugstatements: 27 ms- Success!
在 php.ini 中,注释掉所有Xdebug语句: 27 ms- 成功!
The sad part is, I make mistakes and need Xdebug :-(
可悲的是,我犯了错误,需要 Xdebug :-(
回答by Dzikri Ulinnuha A. Zamroni
I solve my problem with xdebug idekey setting (xdebug.idekey="xdebug1"), and chrome extension xdebug helper (https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc)
我用 xdebug idekey 设置 (xdebug.idekey="xdebug1") 和 chrome 扩展 xdebug helper ( https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc)解决了我的问题
*Dont forget to disable remote_autostart (xdebug.remote_autostart=0)
*不要忘记禁用remote_autostart (xdebug.remote_autostart=0)
Only activating debug (xdebug) by request, using idekey setting, so if debug not needed php processing can be faster/normal, tonggle by button with chrome extension
仅通过请求激活调试 (xdebug),使用 idekey 设置,因此如果不需要调试,php 处理可以更快/正常,通过带有 chrome 扩展的按钮进行切换
I'm using xampp 1.8.3 on windows 10 64bit, i use custom idekey, xdebug.idekey="xdebug1", same with xdebug helper setting
我在 Windows 10 64 位上使用 xampp 1.8.3,我使用自定义 idekey,xdebug.idekey="xdebug1",与 xdebug 助手设置相同
[XDebug]
zend_extension = "E:\xampp183\php\ext\php_xdebug.dll"
xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "E:\xampp183\tmp"
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_autostart=0
xdebug.idekey="xdebug1"
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
xdebug.trace_output_dir = "E:\xampp183\tmp"
xdebug.remote_log="E:\xampp183\tmp\xdebug\xdebug.log"
Now breakpoint/debug activated only if session is requsted via xdebug helper
现在仅当通过 xdebug 助手请求会话时才激活断点/调试
回答by Carsten Wartmann
I excluded my website folder and my xampp folder in Windows Defender and things were solved here.
我在 Windows Defender 中排除了我的网站文件夹和 xampp 文件夹,事情就在这里解决了。
回答by ALEX MAURICIO HENAO HERNANDEZ
I Had the same problem with xampp, and the problem was WINDOWS DEFENDER, if you disable the windows defender protection, xampp is faster (normal speed), Also you can search the xampp folder as exlusion in windows defender. these is the solution.
我和xampp有同样的问题,问题是WINDOWS DEFENDER,如果你禁用windows Defender保护,xampp会更快(正常速度),你也可以在windows Defender中搜索xampp文件夹作为排除。这些就是解决方案。
回答by Fuxi
For chrome users: I found out (after trying all hints above) that the Chrome extension "Evernote Web Clipper" is also slowing down chrome. When loading a plain URL without any includes: enabled / disabled Evernote Web Clipper: 0,7ms / 0,25ms
对于 chrome 用户:我发现(在尝试了上述所有提示后)Chrome 扩展程序“Evernote Web Clipper”也在降低 chrome 的速度。当加载没有任何内容的普通 URL 时:启用/禁用 Evernote Web Clipper:0,7ms / 0,25ms
回答by Zudi
I figured out that Eclipse did not end a XDebug session properly. I solved the problem by restarting the debug session and ending it properly.
我发现 Eclipse 没有正确结束 XDebug 会话。我通过重新启动调试会话并正确结束它来解决这个问题。
回答by Ashar Zafar
Solved php - WAMP/XAMPP is responding very slow over localhost / wordpress
已解决 php - WAMP/XAMPP 在 localhost/wordpress 上的响应速度非常慢
The easiest way is that go to c dirive > xamp > php folder > search php.ini > clink on top then find max_execution_time anset it to max_execution_time=300 > now restart xamp > all done :)
最简单的方法是转到 c dirive > xamp > php 文件夹 > 搜索 php.ini > clink on top 然后找到 max_execution_time 将其设置为 max_execution_time=300 > 现在重新启动 xamp > 全部完成 :)
max_execution_time=300
回答by Daniel D
for me has been an improvement after changing all of above to change from https://localhostto https://127.0.0.1
我更改所有的以上变化之后,已经有所改善//本地主机:HTTPS来https://127.0.0.1