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

猜你喜欢

转载自www.cnblogs.com/behindman/p/9829282.html