- 从 https://www.apachelounge.com/download/、php.net、https://xdebug.org/download上下载相关版本的二进制文件:
a. php要下载Thread Safe版本,否则没有带apache module dll ,目前最新的是 php-8.5.2-Win32-vs17-x64.zip (最好选64bit ,因为xdebug已经没有32bit提供了)
需要留意xdebug和apache要根据php的版本、编译器、php版本、x86/x64选择对应的文件下载:
b. apachelouge上已没有VS17编译的版本了,我是在CSDN上找到一个VS17的版本:(https://download.csdn.net/download/qq_18931093/88633123)
c. xdebug 我选的是php_xdebug-3.5.0-8.5-ts-vs17-x86_64.dll (ThreadSafe版本vs17编译的64bit for php8.5)
..
2. 配置httpd.conf,关键在于要在httpd.conf中把依赖dll先加载进来:
#先加载依赖DLL
LoadFile C:\soft\php-8.5.2-Win32-vs17-x64\icudt77.dll
LoadFile C:\soft\php-8.5.2-Win32-vs17-x64\icuin77.dll
LoadFile C:\soft\php-8.5.2-Win32-vs17-x64\icuio77.dll
LoadFile C:\soft\php-8.5.2-Win32-vs17-x64\icuuc77.dll
LoadFile C:\soft\php-8.5.2-Win32-vs17-x64\libcrypto-3-x64.dll
LoadFile C:\soft\php-8.5.2-Win32-vs17-x64\libssl-3-x64.dll
LoadFile C:\soft\php-8.5.2-Win32-vs17-x64\libssh2.dll
LoadFile C:\soft\php-8.5.2-Win32-vs17-x64\nghttp2.dll
#再加载php 模块
LoadModule php_module C:\soft\php-8.5.2-Win32-vs17-x64\php8apache2_4.dll
PHPIniDir C:\soft\php-8.5.2-Win32-vs17-x64
# 最后是常规设置
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
DirectoryIndex index.php index.html
3. php.ini设置
; 设置扩展目录(要设置为绝对路径,要不apache找不到扩展)
extension_dir = "C:\soft\php-8.5.2-Win32-vs17-x64\ext"
; 启用常用扩展
extension=curl
extension=mbstring
extension=mysqli
extension=intl
; 错误日志(调试程序时,推荐把apache、php的日志都写到一个目录下)
log_errors = On
error_log = "C:/alllogs/logs/php_errors.log"
[xdebug]
; 加载扩展
zend_extension = "php_xdebug-3.5.0-8.5-ts-vs17-x86_64.dll"
; 启用调试模式
xdebug.mode = debug,develop
; 设置 IDE 调试客户端
xdebug.client_host = 127.0.0.1
xdebug.client_port = 9003
; 自动启动调试会话
xdebug.start_with_request = yes