天天看點

Mac 搭建後端PHP+Go環境

準備工作

1. 安裝brew指令

#很慢很慢。。
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
           

替換國内源:

#下載下傳腳本
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_install
#替換國内源
BREW_REPO = “https://github.com/Homebrew/brew“.freeze 
BREW_REPO = "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git".freeze 
#執行
chmod 777 brew_install
./brew_install
           

安裝PHP環境

安裝lnmp

1.Nginx

• 安裝nginx brew install nginx
• 啟動nginx sudo nginx
• 通路 http://localhost:8080/
           

2.安裝php

  • 蘋果是自帶PHP的,如果不是要的版本可以安裝其他版本再切換
  • 安裝PHP
brew install php72
           
  • 直接安裝7.2然後切換版本(推薦)
brew link [email protected] --force --overwrite
 echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.bash_profile
 echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.bash_profile
           
  • 檢視php.ini目錄
php --ini
php -v 
php -m
           

3.安裝mysql

brew install mysql56
           

4.更換composer源

最近換了mac好多的用不習慣安裝了composer但是下載下傳不了laravel.

執行以下指令再下載下傳laravel

sudo composer config -g repo.packagist composer https://packagist.phpcomposer.com
           

安裝swoole

pecl install swoole
           

private/tmp/pear/install/xdebug/xdebug.c:25:10: fatal error: 'php.h' file not found

brew doctor
與
brew link --overwrite php
           

lixindeMBP:~ lixin$ brew link --overwrite [email protected]

Warning: [email protected] is keg-only and must be linked with --force

If you need to have this software first in your PATH instead consider running:

echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.bash_profile

echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.bash_profile

lixindeMBP:~ lixin$ echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.bash_profile
lixindeMBP:~ lixin$ echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.bash_profile
lixindeMBP:~ lixin$ source ~/.bash_profile
           

安裝Go環境

1.Go編譯器安裝

  • 官網下載下傳安裝包,比較快
  • brew install go

  • 添加環境變量
//編輯~/.bash_profile檔案
 vim ~/.bash_profile

//在~/.bash_profile檔案中添加以下2條指令
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin

export PATH="/Users/lixin/go/bin:$PATH"

//使配置生效
localhost:~ zxy$ source ~/.bash_profile
           

2.Goland的配置

參考:

https://blog.csdn.net/zxy_666/article/details/80182688

核心步驟:

Mac 搭建後端PHP+Go環境
Mac 搭建後端PHP+Go環境

其他軟體

1.抓包破解

Registered Name:  https://zhile.io
License Key:  48891cf209c6d32bf4
           

2.phpStrom

漢化:
點選應用程式–>右擊PhpStorm選擇顯示包内容–>Contents–>lib
           
mac

繼續閱讀