Home  >  Article  >  Backend Development  >  How to add php and mysql commands to environment variables under Linux system

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

不言
不言Original
2018-04-16 17:32:311708browse

This article introduces the method of adding php and mysql commands to environment variables under the Linux system. It has certain reference value. Now I share it with you. Friends in need can refer to it

After installing php and MySQL on the Linux CentOS system, for ease of use, you need to add the php and mysql commands to the system commands. After installing php and MySQL on the Linux CentOS system, for ease of use, you need to add the php and mysql commands to the system commands. If they are not added to the environment variables before, execute the "php -v" command to view the current php version information. , an error that the command does not exist will be prompted. Below we will introduce in detail how to add 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
Using this method will only be effective for the current session, which means that whenever you log out or log out of the system, the PATH setting will become invalid and 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 PATH= After the line $PATH:$HOME/bin
This method only takes effect for the currently logged in user
Method 3: Modify the /etc/profile file to make it permanent and effective for all system users To take effect, 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 point command ./profile to make the modification effective. After execution, you can use the echo $PATH command to check whether the addition is successful.

Related recommendations:

PHP and MySQL realize optimization statistics of daily data

Configure PHP and MySQL environments to implement dynamic website code Example

The above is the detailed content of How to add php and mysql commands to environment variables under Linux system. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn