1. 下载
?? | ?? |
---|---|
VS Code | https://go.microsoft.com/fwlink/?Linkid=852157 |
apache2.4.33 | https://www.apachelounge.com/download/VC14/binaries/httpd-2.4.33-win32-VC14.zip |
php7.1.19 | https://windows.php.net/downloads/releases/php-7.1.19-Win32-VC14-x86.zip |
vc_redist.x86 | https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x86.exe |
可以下载不同的apache和php版本,注意Win32和VC14这两部分要一致
https://www.apachelounge.com/download/
https://windows.php.net/download/
2. 安装
2.1 php
将php-7.1.19-Win32-VC14-x86.zip
解压到C盘(其他盘也可以),并改文件夹名为php
将C:\php;C:\Apache24\bin;
添加到环境变量
打开C:\php
, 将php.ini-development
或php.ini-production
重命名为php.ini
2.2 apache
将httpd-2.4.33-win32-VC14.zip
解压到C盘,并改文件夹名为Apache24
修改配置文件
"C:\Apache24\conf\httpd.conf"
"C:\Apache24\conf\httpd.conf"
取消ServerName www.example.com:80
的注释,并改成ServerName localhost:80
确保以下配置的路径正确
DocumentRoot "c:/Apache24/htdocs"
<Directory "c:/Apache24/htdocs">
ScriptAlias /cgi-bin/ "c:/Apache24/cgi-bin/"
<Directory "c:/Apache24/cgi-bin">
添加
LoadModule php7_module C:\php\php7apache2_4.dll
PHPIniDir "C:\php\php.ini"
AddType application/x-httpd-php .php .pap .phtml
双击httpd.exe
浏览器打开127.0.0.1
,出现it works!
说明apache正常运行
安装服务
C:\Apache24\bin> httpd -k install -n "Apache"
- 删除服务(管理员模式,两种方方法)
sc delete service_name
httpd -k uninstall -n "Apache"
- 启动和关闭服务
net start Apache
net stop Apache
2.3 VS Code
1.安装插件PHP Debug
, PHP IntelliSense
2.File->Preference->Settings
修改这三项, php的路径修改为自己的路径
"php.executablePath": "c:/php/php.exe",
"php.validate.executablePath": "c:/php/php.exe",
"php.suggest.basic": false,
3.安装XDebug
https://xdebug.org/files/php_xdebug-2.6.0-7.1-vc14.dll
将下载下来的dll扔到c:/php/ext
中
修改php.ini
[xdebug]
zend_extension = "C:\php\ext\php_xdebug-2.6.0-7.1-vc14.dll"
xdebug.remote_enable = On
;启用性能检测分析
;xdebug.profiler_enable = On
;启用代码自动跟踪
xdebug.auto_trace=On
xdebug.profiler_enable_trigger = On
xdebug.profiler_output_name = cachegrind.out.%t.%p
;指定性能分析文件的存放目录
;xdebug.profiler_output_dir ="C:/wamp64/tmp"
xdebug.show_local_vars=0
;配置端口和监听的域名
xdebug.remote_port=9000
xdebug.remote_host="localhost"
第一次运行项目的时候选择PHP
会出现Listen for XDebug
,
Launch currently open script
两种运行方式,选择Listen for XDebug
就可以进行调试了
调试的时候如果无法命中断点,应该想想此断点处的代码是否会被执行到
原文地址:https://www.cnblogs.com/arcsinw/p/9416318.html