What is $PATH?
PATH is an environmental variable in Linux and other Unix-like operating systems like Mac that tells the shell which directories to search for executable files (i.e., ready-to-run programs) in response to commands issued by a user.
How to see the path content
open the shell or terminal and add the following code:
1 2 3 4 5 | echo $PATH |
Add the path using the command line
To add path you can also use the following way in terminal
1 2 3 4 5 | export PATH=$PATH:~/php7.3/bin |
The above code will add the path to the following file
1 2 3 4 5 | /etc/paths |
Alternative: Modify the bash_profile and add php to it
run the following code to edit tha path file:
1 2 3 4 5 | nano ~/.bash_profile |
To add the php, add the new line to the path to link to the php bin file line below:
1 2 3 4 5 | export PATH=/usr/local/php7.3.0/bin/:$PATH |
PS: If you want this to be run every time you open terminal put it in the file .bash_profile
, which is run when Terminal opens, like the following MySQL command
1 2 3 4 5 | export PATH=/usr/local/mysql/bin/:$PATH |