linux下设置php执行命令

第一种方法:

打开用户根目录下的:

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

修改后保存

然后执行

source ~/.bash_profile 

测试一下 php -v

第二种方法:

设置环境变量 :修改/etc/profile文件使其永久性生效,并对所有系统用户生效,在文件末尾加上如下两行代码

PATH=$PATH:/usr/local/php/bin
export PATH

然后执行生效命令

source /etc/profile

查看PHP版本信息

php -v
原文地址:https://www.cnblogs.com/houdj/p/9011098.html