最新消息: 新版网站上线了!!!

linux/centos/redhat php和mysql添加环境变量profile

、命令:
执行命令:vi /etc/profile
在profile文件中输入如下命令
mysql对应环境变量设置:export PATH=/usr/local/mysql/bin:$PATH
php对应环境变量设置  :export PATH=$PATH:/usr/local/php/bin
实际操作中根据自己的安装目录修改/usr/local/mysql/bin和/usr/local/php/bin

二、修改之后的内容如下:
# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
export PATH=/usr/local/mysql/bin:$PATH
export PATH=$PATH:/usr/local/php/bin
pathmunge () {
    case ":${PATH}:" in
        *:"$1":*)
            ;;
        *)
            if [ "$2" = "after" ] ; then
                PATH=$PATH:$1
            else
                PATH=$1:$PATH
            fi
    esac
}

三、执行source  /etc/profile   让修改过的profile文件立即生效

转载请注明:谷谷点程序 » linux/centos/redhat php和mysql添加环境变量profile