用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. 安卓TV开发(前言)— AndroidTV模拟器初识与搭建

    原文:http://blog.csdn.net/sk719887916/article/details/39612577skay 前言:移动智能设备的发展,推动了安卓另一个领域,包括智能电视和智能家居 ...

  2. 关于通过ruby互联网同步时间的几个思路

    我开始的思路是通过ruby的网络抓包能力,直接从时间同步网页抓取时间.但实际操作中发现很多时间网页都用的是js脚本计算的时间,直接抓成html文件,本地打开后会发现时间显示处都是空白. 比如网上朋友帮 ...

  3. The 3rd tip of DB QueryAnalyzer

     The 3rd tip of DB Query Analyzer Ma Genfeng (Guangdong Unitoll Services incorporated, Guangzhou 510 ...

  4. JS(面试中的变量类型和计算问题)

    JS(变量类型和计算) 题目1.JS 中使用 typeof 能得到那些类型? 题目2.何时使用 === 何时使用==? 题目3.JS 中有哪些内置函数? 题目4.JS 变量按照存储方式区分为那些类型, ...

  5. Math类的方法应用

    class Mortgage { public static void main(String[]args) { double P=Double.parseDouble(args[0]); doubl ...

  6. 安装Emacs并设置racket环境

    最近在阅读sicp这本书,书中的代码是使用scheme实现的.之前阅读的时候是使用Dr.Racket来完成写练习的,可我觉得与其这样,不如一步到位,使用emacs+lisp解释器来的比较快. 安装em ...

  7. Linux部署集群.NET网站

    一.Linux下面安装需要软件 我们这里需要安装的软件有: 1) Mono 3.2.8 : C#跨平台编译器,能使.Net运行与Linux下,目前.net 4.0可以完美运行在该平台下 2) ngin ...

  8. Mybatis 系列7

    上篇系列6中 简单地给mybatis的配置画上了一个句号.那么从本篇文章开始,将会介绍mapper映射文件的配置. 这是mybatis的核心之一 一定要学好 在mapper文件中,以mapper作为根 ...

  9. kindeditor修改允许上传的图片、视频、音频大小

    在jsp文件夹下,有个upload_json.jsp文件,打开找到: //最大文件大小 ; 修改数值即可.默认1000000,即为1M.

  10. java之Spring(AOP)-Annotation实现添加切面

    我们已经知道之前的切面添加方式(动态代理),是定义了一个实现了InvocationHandler接口的Handlerservice类,然后 在这个类内部写好切面逻辑,包括切面放置的位置,很显然下面的这 ...