Add php and mysql commands to environment variables under linux system

  
                  

After installing php and MySQL on Linux CentOS system, in order to use it easily, you need to add php and mysql commands to the system command. If you do not add to the environment variable, execute the “php -v” command to view the current When the php version information is used, it will prompt the command does not exist. Below we will introduce the method of adding php and mysql to the environment variable under linux (assuming php and mysql are installed in /usr/local/webserver/php/respectively). And /usr/local/webserver/mysql/).

Method 1: Run the command export PATH=$PATH:/usr/local/webserver/php/bin and export PATH=$PATH:/usr/local/webserver/mysql/bin

Using this method, it will only be valid for the current session, which means that the PATH setting will be invalid after each logout or logout of the system, but only 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=$PATH: $HOME/bin after a line

This method only works 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/The profile or the execution point command ./profile makes its modification take effect. After the execution, you can check whether the addition is successful by using the echo $PATH command.

Copyright © Windows knowledge All Rights Reserved