How to add php and mysql commands to environment variables under linux system

After installing php and MySQL on the Linux CentOS system, for the convenience of use, you need to add the php and mysql commands to the system commands. If they are not added to the environment variables, execute the "php -v" command to view the current php version information. , it will prompt an error that the command does not exist. Below we will introduce in detail the method of adding php and mysql to the environment variables under linux (assuming that php and mysql are installed in /usr/local/webserver/php/ and /usr/ respectively local/webserver/mysql/).
Method 1: Directly run the commands export PATH=$PATH:/usr/local/webserver/php/bin and export PATH=$PATH:/usr/local/webserver/mysql/bin
Use this method, which will only be valid for the current session , that is to say, whenever you log out or log out of the system, the PATH setting will be invalid, but it will only take effect temporarily.
Method 2: Execute vi ~/.bash_profile to modify the PATH line in the file, and add /usr/local/webserver/php/bin and /usr/local/webserver/mysql/bin to the PATH=$PATH:$HOME/bin line
This method is only valid for the currently logged in user
Method 3: Modify the /etc/profile file to make it permanent and valid for all system users, add the following two lines of code at the end of the file
PATH=$PATH:/usr/local/ webserver/php/bin:/usr/local/webserver/mysql/bin
export PATH
Finally: Execute the command source /etc/profile or execute the command ./profile to make the modification take effect. After execution, you can check whether the addition is successful through the echo $PATH command.

Reference: http://www.jb51.net/LINUXjishu/64971.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326349421&siteId=291194637