第一种方法:打开用户根目录下的:vi ~/.bash_profile # .bash_profile# Get the aliases and functionsif [ -f ~/.bashrc ]; then. ~/.bashrcfi# User specific environment and startup programsPATH=$PATH:$HO...
第一种方法:
打开用户根目录下的:
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
沃梦达教程
本文标题为:linux下设置php执行命令
基础教程推荐
猜你喜欢
- PHP+MySQL+sphinx+scws实现全文检索功能详解 2023-01-31
- php数组函数序列之array_sum() – 计算数组元素值之和 2024-01-15
- PHP判断一个字符串是否是回文字符串的方法 2024-01-31
- PHP手机短信验证码实现流程详解 2022-10-18
- Yii框架连表查询操作示例 2023-02-13
- PHP实现抽奖系统的示例代码 2023-06-26
- PHP实现文件下载【实例分享】 2024-04-27
- php实现构建排除当前元素的乘积数组方法 2022-11-23
- php实现数组筛选奇数和偶数示例 2024-02-05
- 设定php简写功能的方法 2023-03-17
