after installing PHP and MySQL on a Linux CentOS system, for ease of use, PHP and MySQL commands need to be added to the system commands, and if the "php-v" command is used to view the current PHP version information before being added to the environment variable, You will be prompted for an error that the command does not exist, let's take a look at the methods of adding PHP and MySQL to environment variables under Linux (assuming PHP and MySQL are installed in/usr/local/webserver/php/and/usr/local/respectively). webserver/mysql/).
Method One: Direct Run command export path= $PATH:/usr/local/webserver/php/bin and Export path= $PATH:/usr/local/webserver/mysql/bin
with this method, only the current session is valid, that is, the PATH setting is invalidated whenever the system is logged out or logged off, but it is temporarily in effect.
Method Two: Execute VI ~/.bash_profile Modify the PATH line in the file, adding/usr/local/webserver/php/bin and/usr/local/webserver/mysql/bin to the path= $PATH: After $HOME/bin line
This method only takes effect on the currently logged on user
Method Three: Modify the/etc/profile file to make it permanent, and 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: Executes the command source/etc/profile or execution Point command./profile make its modifications effective, and you can see whether the add succeeds through the Echo $PATH command.
Linux adds PHP to environment variables