日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

用Visual Studio Code Debug世界上最好的语言(Mac篇)

發布時間:2024/4/13 编程问答 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 用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最好的語言吧!

其他部分

  • macOS系統PHP7增加Xdebug
  • Install PEAR and PECL on Mac OS X
  • Xdebug on macOS 10.13 with PHP 7
  • install-configure-xdebug-on-xampp-windows-and-mac
  • installing-pecl-and-pear-on-os-x-10-11-el-capitan-macos-10-12-sierra-macos-10

總結

以上是生活随笔為你收集整理的用Visual Studio Code Debug世界上最好的语言(Mac篇)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。