zoukankan      html  css  js  c++  java
  • 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
    核心步骤:
    配置GoPath
    在这里插入图片描述

    其他软件

    1.抓包破解

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

    2.phpStrom

    汉化:
    点击应用程序–>右击PhpStorm选择显示包内容–>Contents–>lib
    
  • 相关阅读:
    MySQL 重置Mysql root用户账号密码
    Git 在同一台机器上配置多个Git帐号
    JQuery 获取元素到浏览器可视窗口边缘的距离
    JQuery Ztree 树插件配置与应用小结
    JQuery iframe宽高度自适应浏览器窗口大小的解决方法
    JQuery jquerysessionjs插件使用介绍
    JQuery Deferred对象使用小结
    JQuery javascript实现父子页面相互调用
    JavaScript 使用new关键字调用函数
    CSS 让div,span等块级、非快级元素排列在同一行
  • 原文地址:https://www.cnblogs.com/HappyTeemo/p/14596042.html
Copyright © 2011-2022 走看看