Home > Article > Backend Development > How to add php and mysql commands to environment variables under Linux CentOS system
How to add php and mysql commands to environment variables under Linux CentOS system 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 after the PATH=$PATHHOME/bin line 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. Add the following two lines of code at the end of the file [php]
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. Regarding php technical issues welcome to join the group to discuss: 256271784, verification code: cxy, if you don’t write it, the verification will not be passed. |