第一种方法:php
打开用户根目录下的:bash
vi ~/.bash_profile
# .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin export PATH alias php=/usr/local/php/bin/php
修改后保存测试
而后执行spa
source ~/.bash_profile
测试一下 php -vcode
第二种方法:blog
设置环境变量 :修改/etc/profile文件使其永久性生效,并对全部系统用户生效,在文件末尾加上以下两行代码ci
PATH=$PATH:/usr/local/php/bin export PATH
而后执行生效命令it
source /etc/profile
查看PHP版本信息io
php -v