CentOS implements several ways to add the php and mysql commands to environment variables

  • 2020-05-17 07:31:24
  • OfStack

CentOS implements several ways to add the php and mysql commands to environment variables

Preface:

When Linux CentOS is configuring the LAPM environment, for the convenience of adding the PHP and MySQL commands to the system environment commands, let's record several ways to add php and mysql to the environment variables under linux.

If you execute the "php-v" command to see the current version of php before adding it to the environment variable, you will be prompted with an error that does not exist in the command. Let's go into detail on how to add php and mysql to the environment variable under linux.

Suppose php and mysql respectively installed at/usr local/webserver php/and/usr/local/webserver/mysql /.

Method 1:

Run a command directly export PATH = $PATH: / usr/local/webserver/php/bin and export PATH = $PATH: / usr/local/webserver/mysql/bin

With this approach, the PATH Settings are only valid for the current session, which means that every time you log out or log out of the system, the PATH Settings are invalidated, only temporarily.

Method 2:

Perform vi ~ /. bash_profile modify PATH1 line in the file, will/usr/local/webserver/php bin and/usr/local/webserver/mysql/bin joining PATH = $PATH: $HOME/bin1 line

This method only works for the currently logged in user

Method 3:

Modify the /etc/profile file to permanently take effect for all system users, adding 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 effect the change. After execution, you can check if the addition was successful through the echo $PATH command.

Thank you for reading, I hope to help you, thank you for your support of this site!


Related articles: