很久没有作php开发,因为近期要维护php项目,在部署开发环境时错误频出,若是能够调试代码,解决问题就很是方便了。因而基于phpstorm+xdebug配置了能够调试的开发环境,期间也查询参考了不少别人的配置过程,发现不少不是很直观或者有遗漏。如今把个人配置步骤记录于此。php
brew install php71
brew install php71-memcached #项目须要,不须要能够不安装
brew install php71-xdebug
brew install nginx
复制代码
vim ~/homebrew/etc/nginx/servers/drone.conf
复制代码
# 常规配置,可根据本身项目调整
server {
listen 80;
# 按本身的须要配置访问的域名
server_name drone-dev.husor.com;
root /data/wwwroot/drone/;
location ~* \.php {
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
复制代码
点击连接,打开xdebug.ininginx
[xdebug]
; 默认zend_extension路径已经配置好了
zend_extension="/Users/xxx/homebrew/opt/php71-xdebug/xdebug.so"
xdebug.idekey="macgdbp"
xdebug.remote_enable=1
xdebug.profiler_enable=1
xdebug.remote_host="127.0.0.1"
xdebug.remote_port=9001
xdebug.remote_handler="dbgp"
复制代码
Debug port和xdebug.ini中的remote_port一致shell
sudo brew services start nginx
brew services start php71
# 若是已经启动过的,就重启
复制代码
配置自己不难,我遇到的问题是没有配置Debug port,remote_port配置错误。了解了这两点,基本上能够一次成功vim