macbook设置环境变量

macbook设置环境变量

在macbook上安装了phpstudy,然后执行php -v和mysql -v都报错

于是进入phpstudy的安装目录,然后再执行,这样很麻烦,于是做了软链,还是有点麻烦,每次都要./php和./mysql

于是开始设置环境变量,将php和mysql加入环境变量,这样在任何目录都可以直接使用php和mysql命令

如此操作

bash-3.2# pwd

/private/var/root

bash-3.2# cat 

bash-3.2# 

bash-3.2# echo $SHELL

/bin/bash

bash-3.2# cat /etc/bashrc

# System-wide .bashrc file for interactive bash(1) shells.

if [ -z "$PS1" ]; then

   return

fi

PS1='\h:\W \u\$ '

# Make bash check its window size after a process completes

shopt -s checkwinsize

[ -r "/etc/bashrc_$TERM_PROGRAM" ] && . "/etc/bashrc_$TERM_PROGRAM"

export PATH="$PATH:/Applications/phpstudy/Extensions/php/php7.3.11/bin:/Applications/phpstudy/Extensions/MySQL5.7.28/bin"

bash-3.2# source /etc/bashrc

 

然后就可以在任何目录中使用php和mysql了,不用频繁切换目录,很方便。

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: