用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 ...
随机推荐
- C语言实现字符串中(10进制和16进制)转成十进制数
如何将字符串中的10进制数和16进制数提取出来,看以下代码: #include <stdio.h> typedef char TUINT8 ; typedef int TUINT32; T ...
- 面试之路(7)-BAT面试题之计算机的三大原则
1.计算机是执行输入.运算.输出的机器 计 算 机 的 硬 件 由 大 量 的 IC(Integrated Circuit,集成电路)组成.每块 IC 上都带有许多引脚.这些引脚有的用于输入,有的用于 ...
- leetcode之旅(8)-Contains Duplicate
题目: Given an array of integers, find if the array contains any duplicates. Your function should retu ...
- python 字典dict类型合并(不能错过哦)
我要的字典的键值有些是数据库中表的字段名, 但是有些却不是, 我需要把它们整合到一起, 因此有些这篇文章.(非得凑够150个字,我也是没有办法,扯一点昨天的问题吧,话说python中的session就 ...
- oracle索引建立和删除
1.多列建立索引 SQL> create index dex_index2 on dex(sex,name); Index created. SQL> select object_name ...
- Struts2 中的数据传输的几种方式
1. 如何将参数从界面传递到Action? 你可以把Struts2中的Action看做是Struts1的Action+ActionForm,即只需在Action中定义相关的属性(要有gette ...
- nslookup查询结果详解
nslookup可以指定查询的类型,可以查到DNS记录的生存时间还可以指定使用那个DNS服务器进行解释.在已安装TCP/IP协议的电脑上面均可以使用这个命令.主要用来诊断域名系统 (DNS) 基础结构 ...
- unix中的rm,rmdir的使用
一.rm的使用 1.基本用法:用于删除文件 rm filename 2.可加属性值 (1)-v rm -v filename 作用:提示删除的情况 (2)-f rm -f filename 作用:删 ...
- CentOS-Minimal版本下安装telnet服务和xinetd服务
默认在CentOS-Minimal版本下没有安装telnet和xinetd服务. 1.安装telnet [root@localhost ~]# rpm -qa | grep telnet --检查是 ...
- mybatis源码解读(五)——sql语句的执行流程
还是以第一篇博客中给出的例子,根据代码实例来入手分析. static { InputStream inputStream = MybatisTest.class.getClassLoader().ge ...