Linux adds PHP to environment variables

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.