用Visual Studio Code Debug世界上最好的语言(Mac篇)
用Visual Studio Code Debug世界上最好的语言(Mac篇)
首先,你要有台Macbook Pro,接着才继续看这个教程.
PS:Windows用户看这里用Visual Studio Code Debug世界上最好的语言
brew 环境准备
见brew.sh,或者
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
PHP7 + nginx + php-fpm + xdebug
PHP7
brew install php@7.1
安装完了之后看下安装路径:
where php;
##➜ ~ where php
## /usr/local/opt/php@7.1/bin/php
## /usr/bin/php
一般php.ini在/usr/local/etc/php/7.1
ls /usr/local/etc/php/7.1
#conf.d pear.conf php-fpm.conf php-fpm.d php.ini
待会我们配置xdebug和php-fpm的时候会用到这个这些配置文件的,先跳过
xdebug安装
本来其实一句brew install php71-xdebug --without-homebrew-php就完事的,谁知道homebrew-php最近被移除了,所以就尴尬了...
手动去下载xdebug然后配置吧.下载页面:https://xdebug.org/files/
选择自己要安装的版本,我这里选了2.6.
# 创建一个你喜欢的路径存放,我放在了~/tool/目录下;
mkdir tool;
wget https://xdebug.org/files/xdebug-2.6.0.tgz;
# 解压
tar xvzf xdebug-2.6.0.tgz;
cd xdebug-2.6.0;
# 初始化php模块
phpize;
# 生成对应的so文件
# ./configure --enable-xdebug --with-php-config=PHP安装路径/bin/php-config;
./configure --enable-xdebug --with-php-config=/usr/local/Cellar/php@7.1/7.1.17/bin/php-config;
# 上一步正常执行完毕之后会在xdebug-2.6.0/modules/文件夹下生成xdebug.la和xdebug.so,待会我们在php.ini中配置xdebug会用到这个文件
安装nginx
brew install nginx
配置nginx.conf
安装完成之后开始配置nginx,首先创建一堆需要用到的文件件.
mkdir -p /usr/local/var/logs/nginx
mkdir -p /usr/local/etc/nginx/sites-available
mkdir -p /usr/local/etc/nginx/sites-enabled
mkdir -p /usr/local/etc/nginx/conf.d
mkdir -p /usr/local/etc/nginx/ssl
sudo mkdir -p /var/www
sudo chown :staff /var/www
sudo chmod 777 /var/www
#作者:GQ1994
#链接:https://www.jianshu.com/p/a642ee8eca9a
#來源:简书
#著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
然后vim /usr/local/etc/nginx/nginx.conf 输入以下内容:
user root wheel; #默认的是nobody会导致403
worker_processes 1;
error_log /usr/local/var/logs/nginx/error.log debug;
pid /usr/local/var/run/nginx.pid;
events {
worker_connections 256;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /usr/local/var/logs/access.log main;
sendfile on;
keepalive_timeout 65;
port_in_redirect off;
include /usr/local/etc/nginx/sites-enabled/*;
}
设置nginx php-fpm配置文件
vim /usr/local/etc/nginx/conf.d/php-fpm
修改为(没有则创建)
#proxy the php scripts to php-fpm
location ~ \.php$ {
try_files $uri = 404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_intercept_errors on;
include /usr/local/etc/nginx/fastcgi.conf;
}
创建默认虚拟主机default
vim /usr/local/etc/nginx/sites-available/default输入:
server {
listen 80;#如果80被用了可以换成别的,随你开心
server_name www.qilipet.com admin.qilipet.com;
root /var/www/pet/public;
access_log /usr/local/var/logs/nginx/default.access.log main;
index index.php index.html index.htm;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php?$query_string;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
此部分内容基本来自GQ1994:mac下配置php、nginx、mysql、redis
配置php.ini
回到我们的/usr/local/etc/php/7.1文件夹
在php.ini中加入xdebug配置
[xdebug]
;zend_extension="刚刚的xdebug路径/modules/xdebug.so"
zend_extension="~/tool/xdebug-2.6.0/modules/xdebug.so"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 1
;默认的9000已经被php-fpm占用了,切记换一个端口
xdebug.remote_port = 9001
xdebug.scream = 0
xdebug.show_local_vars = 1
重启一下php-fpm和nginx,看一下php是不是都正常跑起来了.
VS Code配置
User Settings配置PHP目录
"php.executablePath": "/usr/local/opt/php@7.1/bin/php"
安装php debug插件
安装完成之后配置一下launch.json
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9001 //默认是9000已经被php-fpm占用,上一步我们配置远程端口是9001
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9001 //默认是9000已经被php-fpm占用,上一步我们配置远程端口是9001
}
]
}
然后就愉快debug最好的语言吧!

其他部分
用Visual Studio Code Debug世界上最好的语言(Mac篇)的更多相关文章
- 用Visual Studio Code Debug世界上最好的语言
前言 这阵子因缘巧合接手了一个辣鸡项目,是用世界上最好的拍黄片写的,项目基本是另一个小伙伴在撸码,我就兼职打杂和发布做点运维的工作. 然后昨天项目上了测试版之后,一用起来Error满天飞了.让小伙伴查 ...
- ASP.NET Core 中文文档 第二章 指南(1)用 Visual Studio Code 在 macOS 上创建首个 ASP.NET Core 应用程序
原文:Your First ASP.NET Core Application on a Mac Using Visual Studio Code 作者:Daniel Roth.Steve Smith ...
- Visual Studio Code 1.0发布:100+语言,300+pull请求,1000+扩展
在第一个预览版发布一年后,微软发表了Visual Studio Code 1.0. 在//BUILD 2015大会上,微软宣布,他们的一个团队需要几个月来创建Visual Studio Code的第一 ...
- 再整理:Visual Studio Code(vscode)下的通用C语言环境搭建
版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://www.cnblogs.com/czlhxm/p/11794743.ht ...
- 在ubuntu下使用visual studio code编写python
感觉有了visual studio code之后,不管编写什么语言的代码都可以,简单安装对应的语言插件即可. 这不轮到了最近比较热的python语言,蹭着AI的热度,python语言成为了工程师们又一 ...
- Visual Studio Code 使用 Typings 实现智能提示功能
前言 我们知道在IDE中代码的智能提示几乎都是标配,虽然一些文本编辑器也有一些简单的提示,但这是通过代码片段提供的.功能上远不能和IDE相比.不过最近兴起的文本编辑器的新锐 Visual Studio ...
- Visual Studio Code IDE开发插件配置
[PHP通用集成环境] PHP Extension Pack #PHP拓展包,PHP开发最重要的拓展 PHP Intelephense #PHP自动补全工具 PHP IntelliSense #PHP ...
- Visual Studio Code(VS code)介绍
一.日常安利 VS code VS vode特点: 开源,免费: 自定义配置 集成git 智能提示强大 支持各种文件格式(html/jade/css/less/sass/xml) 调试功能强大 各种方 ...
- Visual Studio Code - 调试 Node.js 代码
官方的文档写的太好了!大家还是看参考资料吧. 参考资料: Debugging in Visual Studio Code Debug Node.js Apps using Visual Studio ...
随机推荐
- Docker 基础技术之 Linux cgroups 详解
PS:欢迎大家关注我的公众号:aCloudDeveloper,专注技术分享,努力打造干货分享平台,二维码在文末可以扫,谢谢大家. 推荐大家到公众号阅读,那里阅读体验更好,也沉淀了很多篇干货. 前面两篇 ...
- How--to-deploy-smart-contracts-on
The following smart contract code is only an example and is NOT to be used in Production systems. pr ...
- oracle的for和i++
很长时间没用oracle的储存了,这次用到一次i++i++的sql语句:declarei_1 number(30) :=0;begin i_1 :=i_1+1;//i_1=1 insert into ...
- Android弹幕功能实现,模仿斗鱼直播的弹幕效果
转载出处:http://blog.csdn.net/sinyu890807/article/details/51933728 本文同步发表于我的微信公众号,扫一扫文章底部的二维码或在微信搜索 郭霖 即 ...
- 关于国际化时报org.springframework.context.NoSuchMessageException错,具体到No message found under code '你的键名' for locale 'zh_CN'.的解决方案
使用IntelliJ IDEA开发工具解决方案: 总结原因,解决方案: 1,在使用messageSource.getMessage方法时,参数1的键名跟属性文件中键名不一致,比如Controller中 ...
- 获取radio、select、checkbox标签选中的值
<input type="radio" id="radio1" name="radio"><label for=" ...
- WebApi PUT、DELETE请求时出现405 - 不允许用于访问此页的 HTTP 谓词。
开发时,新建WebApi项目需要用到Restful规范,此时请求有POST\PUT\DELETE\GET等请求 此时需要在web.config中加入 <system.webServer> ...
- Java经验杂谈(2.对Java多态的理解)
多态是面向对象的重要特性之一,我试着用最简单的方式解释Java多态: 要正确理解多态,我们需要明确如下概念:・定义类型和实际类型・重载和重写・编译和运行 其中实际类型为new关键字后面的类型. 重载发 ...
- Scala编程入门---面向对象编程之对象
对象 Object,相当于class单个实例,通常在里面放一些静态的filed或method 第一次调用object方法时候,就会执行object的constructor,也就是Object中不在me ...
- Kudu vs HBase
本文由 网易云发布. 背景 Cloudera在2016年发布了新型的分布式存储系统--kudu,kudu目前也是apache下面的开源项目.Hadoop生态圈中的技术繁多,HDFS作为底层数据存储的 ...