Mar*_*tin 25 php windows apache xampp
我在Windows 7旗舰版上运行XAMPP 1.7.1.除了速度之外,一切(Apache和MySQL)都运行良好.
当我打开http:// localhost /时,我必须等待1-3秒才能查看网页.在我看来,它应该最多几百毫秒.
基本事实:
我做了一个简单的基准PHP脚本来测试HDD/CSS速度:
<?php
function getmicrotime() {
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
function testReadWrite() {
$timeStart = getmicrotime();
$filename = "test.txt";
file_put_contents( $filename, '' ); // prepare empty file
for ( $i = 0; $i < 1000; $i++ ) {
$a = file_get_contents( $filename );
file_put_contents( $filename, $a . '.' );
}
return round( getmicrotime() - $timeStart, 3 );
}
function testCpuSpeed() {
$timeStart = getmicrotime();
$var = '';
for ( $i = 0; $i < 100000; $i++ ) {
$var = sha1( md5( $i * $i * $i * $i * $i * $i * $i * $i * $i * $i ) );
}
return round( getmicrotime() - $timeStart, 3 );
}
echo "Read/write #1: " . testReadWrite() . "<BR>";
echo "Read/write #2: " . testReadWrite() . "<BR>";
echo "Read/write #3: " . testReadWrite() . "<BR>";
echo "CPU speed #1: " . testCpuSpeed() . "<BR>";
echo "CPU speed #2: " . testCpuSpeed() . "<BR>";
echo "CPU speed #3: " . testCpuSpeed() . "<BR>";
?>
Run Code Online (Sandbox Code Playgroud)
我的电脑结果:
网站托管结果:
我服务器的一个结果(就像我的PC一样闲置计算机,但速度稍快一点):
所以我不认为这是因为我的PC速度,但我确信还有一些问题.您是否对Windows 7(或Vista)上的XAMPP速度有一定的经验?
谢谢.
小智 43
如果在Windows 7下XAMP很慢,则防火墙设置没有区别.
Security Essentials防病毒没有任何区别.
要解决这个问题,两个有很大不同的地方是:
1)在windows\system32\drivers\etc\hosts中添加以下行:
127.0.0.1 127.0.0.1
127.0.0.1 localhost
2)如果您正在使用PHP,则在XAMP php.ini文件中取消注释eaccelerator行:
zend_extension ="C:\ xampp\php\ext\php_eaccelerator_ts.dll"
在这两个更改之后,重新启动Apache,它会更快.
Pas*_*TIN 15
不确定这可能是你的问题的原因,但这可能是一个想法:你有一个看起来像这样的行:
::1 localhost
Run Code Online (Sandbox Code Playgroud)
在你的主机(它应该在某个地方C:\WINDOWS\system32\drivers\etc\hosts
,如果我没记错的话)文件?
如果是,请通过#
在开头添加a来评论该行.
这样,关于localhost的唯一一行应该是
127.0.0.1 localhost
Run Code Online (Sandbox Code Playgroud)
这是一个IPv4地址; 而你评论的那个是IPv6 - 这对你要做的事情没有用.
正如我所说,不确定你的问题是否与此有关,但我已经看到这种消息帮助了几次与你的问题非常相似的问题(即在服务器上做任何事情之前等了很长时间).
Bar*_*rto 15
使用XDEBUG注释PHP.ini中的行:
;[XDebug]
;zend_extension = "C:\xampp\php\ext\php_xdebug.dll"
;xdebug.profiler_append = 0
;xdebug.profiler_enable = 1
;xdebug.profiler_enable_trigger = 0
;xdebug.profiler_output_dir = "C:\xampp\tmp"
;xdebug.profiler_output_name = "cachegrind.out.%t-%s"
;xdebug.remote_enable = 0
;xdebug.remote_handler = "dbgp"
;debug.remote_host = "127.0.0.1"
;xdebug.trace_output_dir = "C:\xampp\tmp"
Run Code Online (Sandbox Code Playgroud)
I disabled Bitdefeender -> no result I added lines to hosts -> no result I disabled xdebug - x2-x3 faster
最好的问候巴托
Ogn*_*yan 11
我和Win 7 + XAMPP有类似的问题.问题是由我的防病毒软件引起的.当启用它时,即使是最简单的PHP页面也需要超过半秒的时间才能打开.带有大量链接require_once()的大PHP脚本花了超过1.5秒.在禁用防病毒功能的情况下,一切都很快(每个简单页面少于100毫秒,对于非常重的东西(100 +链接require_once())大约500毫秒).
我正在使用bitdeffender,这是它的解决方案:
game mode
在使用xampp时切换bitdefenderAntivirus -> Shield -> Advanced Settings -> Exclusions Tab
并添加httpd.exe(位于您的xampp安装/ apache/bin /中)的排除项.然后转到Antivirus -> Exclusions
并为php文件所在的目录添加排除项.不要忘记在执行上述步骤后重启apache.
您可以选择安装eaccelerator来加快速度.
我个人注意到:我发现WAMP作为一个项目比XAMPP更不成熟.
旁注2:最好的解决方案是使用旧PC作为Linux服务器,一切都会像魅力一样:-)
阅读了几个答案后 - 他们没有帮助(我甚至删除了我的防病毒软件).
帮助我显着的是禁用xdebug.现在一切都变得非常快.
尝试一下 Wamp Server 怎么样?
与 XAMPP (44mb) 相比,安装文件要小得多 (16mb)。