1.查看php命令所在位置
[root@localhost swoole-4.5.5]# which php /usr/local/php/bin/php
2.使用全局的方式添加环境变量
vi /etc/profile
3.在文档的末尾添加
PATH=/usr/local/php/bin:$PATH
export PATH
4.让新配置生效
source /etc/profile
5.查看配置是否生效
[root@localhost swoole-4.5.5]# php -v PHP 7.2.9 (cli) (built: Oct 14 2020 12:20:28) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies