Windows 10更新后MAMP Pro出现PHP致命错误无法加载文件
问题概述
运行环境
- 系统:Windows 10
- 集成环境:MAMP PRO Windows v5.0.5
- PHP版本:所有主机统一使用PHP 8.1.0
故障现象
Windows更新并重启电脑前所有站点功能运行正常,重启后访问站点抛出致命错误,初始报错信息如下:
PHP Fatal error: Failed opening required 'C:/Users/Alex Leuschner/OneDrive/Mampilly/Polygon/market-data/index.php' (include_path='.;C:\php\pear') in Unknown on line 0
报错指向的index.php为测试用极简文件,仅包含一行输出代码:
echo 'Hello World';
已做排查操作
- 在C盘根目录安装PEAR,安装过程命令行输出如下:
PS C:\> php go-pear.phar Are you installing a system-wide PEAR or a local copy? (system|local) [system] : system Below is a suggested file layout for your new PEAR installation. To change individual locations, type the number in front of the directory. Type 'all' to change all of them or simply press Enter to accept these locations. 1. Installation base ($prefix) : C:\ 2. Temporary directory for processing : C:\tmp 3. Temporary directory for downloads : C:\tmp 4. Binaries directory : C:\ 5. PHP code directory ($php_dir) : C:\pear 6. Documentation directory : C:\docs 7. Data directory : C:\data 8. User-modifiable configuration files directory : C:\cfg 9. Public Web Files directory : C:\www 10. System manual pages directory : C:\man 11. Tests directory : C:\tests 12. Name of configuration file : C:\WINDOWS\pear.ini 13. Path to CLI php.exe : C:\MAMP\bin\php\php8.1.0 1-13, 'all' or Enter to continue: Beginning install... Configuration written to C:\WINDOWS\pear.ini... Initialized registry... Preparing to install... installing phar://C:/go-pear.phar/PEAR/go-pear-tarballs/Archive_Tar-1.4.14.tar... installing phar://C:/go-pear.phar/PEAR/go-pear-tarballs/Console_Getopt-1.4.3.tar... installing phar://C:/go-pear.phar/PEAR/go-pear-tarballs/PEAR-1.10.13.tar... installing phar://C:/go-pear.phar/PEAR/go-pear-tarballs/Structures_Graph-1.1.1.tar... installing phar://C:/go-pear.phar/PEAR/go-pear-tarballs/XML_Util-1.4.5.tar... warning: pear/PEAR dependency package "pear/Archive_Tar" downloaded version 1.4.14 is not the recommended version 1.4.4 install ok: channel://pear.php.net/Archive_Tar-1.4.14 install ok: channel://pear.php.net/Console_Getopt-1.4.3 install ok: channel://pear.php.net/Structures_Graph-1.1.1 install ok: channel://pear.php.net/XML_Util-1.4.5 install ok: channel://pear.php.net/PEAR-1.10.13 PEAR: Optional feature webinstaller available (PEAR's web-based installer) PEAR: Optional feature gtkinstaller available (PEAR's PHP-GTK-based installer) PEAR: Optional feature gtk2installer available (PEAR's PHP-GTK2-based installer) PEAR: To install optional features use "pear install pear/PEAR#featurename" ****************************************************************************** WARNING! The include_path defined in the currently used php.ini does not contain the PEAR PHP directory you just specified: <C:\pear> If the specified directory is also not in the include_path used by your scripts, you will have problems getting any PEAR packages working. Would you like to alter php.ini <C:\MAMP\bin\php\php8.1.0\php.ini>? [Y/n] : y php.ini <C:\MAMP\bin\php\php8.1.0\php.ini> include_path updated. Current include path : C:\MAMP\bin\php\php8.1.0\ Configured directory : C:\pear Currently used php.ini (guess) : C:\MAMP\bin\php\php8.1.0\php.ini Press Enter to continue: ** WARNING! Old version found at C:\, please remove it or be sure to use the new c:\\pear.bat command The 'pear' command is now at your service at c:\\pear.bat ** The 'pear' command is not currently in your PATH, so you need to ** use 'c:\\pear.bat' until you have added ** 'C:\' to your PATH environment variable. Run it without parameters to see the available actions, try 'pear list' to see what packages are installed, or 'pear help' for help. For more information about PEAR, refer to official PEAR documentation. Thanks for using go-pear! * WINDOWS ENVIRONMENT VARIABLES * For convenience, a REG file is available under C:\PEAR_ENV.reg . This file creates ENV variables for the current user. Double-click this file to add it to the current user registry.
- 手动修改
php.ini中的include_path配置为C:\MAMP\bin\php\php8.1.0\,命令行执行php -i验证配置已生效,返回结果为:include_path => C:\MAMP\bin\php\php8.1.0\ => C:\MAMP\bin\php\php8.1.0\ - 再次访问站点,抛出更新后的错误:
PHP Fatal error: Failed opening required 'C:/Users/Alex Leuschner/OneDrive/Mampilly/Polygon/market-data/index.php' (include_path='C:\MAMP\bin\php\php8.1.0\') in Unknown on line 0
排查解决步骤
这个报错和include_path、PEAR配置没有关系,核心原因是PHP进程无法访问到指定绝对路径下的index.php文件,按以下优先级排查:
- 优先检查OneDrive同步状态:你的站点文件存放在OneDrive同步目录下,Windows更新大概率会重置OneDrive登录状态、同步策略,导致对应文件夹没有同步到本地,文件仅存于云端,本地磁盘路径下实际不存在该文件。打开资源管理器逐层进入目标路径,确认
index.php真实存在,同时检查OneDrive客户端是否正常登录、market-data文件夹是否设置为“始终保留在此设备上”。 - 检查路径合法性:确认路径中所有文件夹名拼写正确,重点排查带空格的
Alex Leuschner目录名是否被修改、路径中是否存在不可见的特殊字符。可临时将站点文件夹移动到不带空格、非OneDrive同步的路径(比如C:\www\market-data),在MAMP中修改站点根目录到新路径后重启服务测试,如果能正常访问即可确认是原路径的问题。 - 检查目录权限:右键点击
market-data文件夹,打开「属性-安全」选项卡,确认MAMP服务运行所使用的系统用户拥有该目录及下属文件的读取、执行权限,Windows更新经常会重置用户目录下的ACL权限配置。 - 校验MAMP站点配置:打开MAMP PRO的主机设置页,确认对应站点的Document Root配置确实指向目标路径,Windows更新可能导致配置文件损坏、路径字段混入不可见字符。注意CLI模式读取的
php.ini和Web服务读取的php.ini不一定是同一个文件,修改配置后必须重启MAMP的Web服务(Apache/Nginx)再测试。 - 排查路径斜杠兼容问题:Windows下PHP虽然兼容正斜杠
/和反斜杠\,但部分MAMP版本的重写规则在处理带空格的正斜杠路径时会出现截断问题,可将路径中带空格的目录重命名为无空格名称,再同步修改MAMP配置测试。
内容的提问来源于stack exchange,提问作者Alexnl
相关产品推荐
相关产品推荐

