用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篇)的更多相关文章

  1. 用Visual Studio Code Debug世界上最好的语言

    前言 这阵子因缘巧合接手了一个辣鸡项目,是用世界上最好的拍黄片写的,项目基本是另一个小伙伴在撸码,我就兼职打杂和发布做点运维的工作. 然后昨天项目上了测试版之后,一用起来Error满天飞了.让小伙伴查 ...

  2. 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 ...

  3. Visual Studio Code 1.0发布:100+语言,300+pull请求,1000+扩展

    在第一个预览版发布一年后,微软发表了Visual Studio Code 1.0. 在//BUILD 2015大会上,微软宣布,他们的一个团队需要几个月来创建Visual Studio Code的第一 ...

  4. 再整理:Visual Studio Code(vscode)下的通用C语言环境搭建

    版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://www.cnblogs.com/czlhxm/p/11794743.ht ...

  5. 在ubuntu下使用visual studio code编写python

    感觉有了visual studio code之后,不管编写什么语言的代码都可以,简单安装对应的语言插件即可. 这不轮到了最近比较热的python语言,蹭着AI的热度,python语言成为了工程师们又一 ...

  6. Visual Studio Code 使用 Typings 实现智能提示功能

    前言 我们知道在IDE中代码的智能提示几乎都是标配,虽然一些文本编辑器也有一些简单的提示,但这是通过代码片段提供的.功能上远不能和IDE相比.不过最近兴起的文本编辑器的新锐 Visual Studio ...

  7. Visual Studio Code IDE开发插件配置

    [PHP通用集成环境] PHP Extension Pack #PHP拓展包,PHP开发最重要的拓展 PHP Intelephense #PHP自动补全工具 PHP IntelliSense #PHP ...

  8. Visual Studio Code(VS code)介绍

    一.日常安利 VS code VS vode特点: 开源,免费: 自定义配置 集成git 智能提示强大 支持各种文件格式(html/jade/css/less/sass/xml) 调试功能强大 各种方 ...

  9. Visual Studio Code - 调试 Node.js 代码

    官方的文档写的太好了!大家还是看参考资料吧. 参考资料: Debugging in Visual Studio Code Debug Node.js Apps using Visual Studio ...

随机推荐

  1. linux内核自旋锁API

    我们大概都了解,锁这种机制其实是为了保护临界区代码的,关于使用和定义,我总结的API如下: #include <linux/spinlock.h> 定义自旋锁 spinlock_t loc ...

  2. C语言高级应用---操作linux下V4L2摄像头应用程序

    我们都知道,想要驱动linux下的摄像头,其实很简单,照着V4L2的手册一步步来写,很快就可以写出来,但是在写之前我们要注意改变系统的一些配置,使系统支持framebuffer,在dev下产生fb0这 ...

  3. obj-c编程03:多个参数方法的定义

    好吧,虽说本猫不能自吹精通十几种语言,但是也见过十几种语言的语法啊.像obj-c这样奇葩,或者说另类的写法还是头一次见到,完整写法我都不知道怎么起方法名了.虽说有简短写法,可和C比起来那个" ...

  4. MOOS学习笔记4——独立线程不同回调

    MOOS学习笔记4--独立线程不同回调 /** * @fn 独立线程不同回调 * @version v1.0 * @author */ #include "MOOS/libMOOS/Comm ...

  5. 详解PNG文件结构

    前言 PNG,JPEG,GIF,BMP作为数据压缩文件,有许多重要的信息我们需要区深度解析. 一.PNG的文件结构 1.1.数据块构成结构 PNG文件结构很简单,主要有数据块(Chunk Block) ...

  6. 项目中Orcale存储过程优化记录

    今天对之前写的Orcale存储过程做了一些优化,使其变得更加灵活,之前写的存储过程是使用游标存储SQL执行结果,但是使用游标带来的弊端是,在声明时,它所执行的SQL就已经被写死,无法修改.若想更加灵活 ...

  7. Google高级搜索技巧十则

    前言:多数人在使用Google搜索的过程是非常低效和无谓的,如果你只是输入几个关键词,然后按搜索按钮,你将是那些无法得到Google全部信息的用户,在这篇文章中,Google搜索专家迈克尔.米勒将向您 ...

  8. java设计模式--单列模式

    java设计模式--单列模式 单列模式定义:确保一个类只有一个实例,并提供一个全局访问点. 下面是几种实现单列模式的Demo,每个Demo都有自己的优缺点: Demo1: /** * 单列模式需要满足 ...

  9. OOP的基本原则

    OOP的基本原则 点击打开链接

  10. JavaScript程序的执行顺序

    JavaScript程序的执行顺序:同步==>异步==>回调 同步是阻塞模式,异步是非阻塞模式.     同步就是指一个进程在执行某个请求的时候,若该请求需要一段时间才能返回信息,那么这个 ...