Welcome to WebmasterWorld Guest from 54.159.50.111

Forum Moderators: bakedjake

Message Too Old, No Replies

Running php and mysql commands at terminal

     
3:41 pm on Nov 8, 2010 (gmt 0)

Full Member

5+ Year Member Top Contributors Of The Month

joined:Sept 30, 2009
posts:222
votes: 0


I'm trying to run php and mysql commands from the command terminal.

I'd like to run commands such as: php mypage.php

But I can't because I get this error: -sh: php: not found

What I have to do is run: /opt/php5/bin/php mypage.php

I can't even find the path to run mysql from the command line, but I know mysql works because it works on the site.

How can I configure my Ubuntu 10.04 setup to allow me to use short commands such as php instead of /opt/php5/bin/php and mysql instead of (how do I find the path?).
6:59 pm on Nov 8, 2010 (gmt 0)

Senior Member from KZ 

WebmasterWorld Senior Member lammert is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 10, 2005
posts: 2886
votes: 1


The path is in the environment variable PATH. The place where you add an extra directory to your path depends on the shell you use, but it is probably the file .bash_profile or .profile in your home directory.

You can extend your path by adding the following two lines to the profile file:

PATH=$PATH:/opt/php5/bin
export PATH


Be sure to logout and login again, because the profile file is only read at login.
8:45 pm on Nov 8, 2010 (gmt 0)

Full Member

5+ Year Member Top Contributors Of The Month

joined:Sept 30, 2009
posts:222
votes: 0


Thank you. I located my .bash_profile. Would I add those two lines in verbatim into the document, or do I need to change anything?
9:09 pm on Nov 8, 2010 (gmt 0)

Senior Member from KZ 

WebmasterWorld Senior Member lammert is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 10, 2005
posts: 2886
votes: 1


If you add these two lines to the end of the file it should work, even if there are other PATH assignment statements in the profile file.