nginx+phpstorm+xdebug环境配置

栏目: PHP · 发布时间: 8年前

内容简介:nginx+phpstorm+xdebug环境配置

好久没有做 php 开发,由于近期要维护php项目,在部署开发环境时错误频出,如果可以调试代码,解决问题就非常方便了。于是基于phpstorm+xdebug配置了可以调试的开发环境,期间也查询参考了很多别人的配置过程,发现很多不是很直观或者有遗漏。现在把我的配置步骤记录于此。

1. 安装php+xdebug+nginx

brew install php71
brew install php71-memcached #项目需要,不需要可以不安装
brew install php71-xdebug
brew install nginx

2. 配置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;
    }
}

3. 配置phpstorm+xdebug

  • 在phpstorm的项目右上角选择Edit Configrations...
    nginx+phpstorm+xdebug环境配置
  • 新建一个PHP Web Application,如我这里的drone
    nginx+phpstorm+xdebug环境配置
  • 点击Server后的按钮,新建一个Server,如我这里的nginx
nginx+phpstorm+xdebug环境配置
  • 打开phpstorm的Preferences,依次选择Languages & Frameworks > PHP,配置前面安装好的php
nginx+phpstorm+xdebug环境配置
nginx+phpstorm+xdebug环境配置

点击链接,打开xdebug.ini

[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"
nginx+phpstorm+xdebug环境配置

Debug port和xdebug.ini中的remote_port一致

4. 启动php+nginx

sudo brew services start nginx
brew services start php71
# 如果已经启动过的,就重启

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。

大转换

大转换

尼古拉斯·卡尔 / 闫鲜宁、张付国 / 中信 / 2016-2 / 49

1、我们这个时代最清醒的思考者之一尼古拉斯·卡尔继《浅薄》《玻璃笼子》之后又一重磅力作。 2、在这部跨越历史、经济和技术领域的著作中,作者从廉价的电力运营方式对社会变革的深刻影响延伸到互联网对我们生活的这个世界的重构性影响。 3、《快公司》《金融时报》《华尔街日报》联袂推荐 简介 早在2003年,尼古拉斯·卡尔先生发表在《哈佛商业评论》上的一篇文章——IT Doesn't ......一起来看看 《大转换》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

html转js在线工具
html转js在线工具

html转js在线工具