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 php@7.2 --force --overwrite
echo \'export PATH="/usr/local/opt/php@7.2/bin:$PATH"\' >> ~/.bash_profile
echo \'export PATH="/usr/local/opt/php@7.2/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 php@7.2
Warning: php@7.2 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/php@7.2/bin:$PATH”\’ >> ~/.bash_profile
echo \’export PATH=”/usr/local/opt/php@7.2/sbin:$PATH”\’ >> ~/.bash_profile
lixindeMBP:~ lixin$ echo \'export PATH="/usr/local/opt/php@7.2/bin:$PATH"\' >> ~/.bash_profile
lixindeMBP:~ lixin$ echo \'export PATH="/usr/local/opt/php@7.2/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
核心步骤:
其他软件
1.抓包破解
Registered Name: https://zhile.io
License Key: 48891cf209c6d32bf4
2.phpStrom
汉化:
点击应用程序–>右击PhpStorm选择显示包内容–>Contents–>lib