Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have XAMPP installed and my PHP is:


Every time I need to execute a PHP file I need to do this:

/opt/lampp/bin/php-5.3.8 testando.php

Is there another way to execute it besides using symbolic link?

I did this on /etc/init.d/:

sudo ln -s /opt/lampp/bin/php-5.3.8 php

Why when I need to run PHP I have to do this ./php instead of just php?

And is there a way to do this without the ./? Like it was installed via apt-get?

share|improve this question

closed as off topic by Thomas Ward, Mitch, Eliah Kagan, RobotHumans, SirCharlo Aug 31 '12 at 12:19

Questions on Ask Ubuntu are expected to relate to Ubuntu within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

include the output of echo $PATH please – Thomas Ward Jun 5 '12 at 16:49
Questions that are about Linux Mint (as you said is what you're running, in a comment to Lord of Time's answer) and not about Ubuntu are off-topic. You should instead ask this somewhere Linux Mint is supported, like the Linux Mint Forums or Unix.SE. – Eliah Kagan Aug 31 '12 at 10:01
up vote 7 down vote accepted

You can create a symlink in /usr/bin to the PHP binary/executable file.

sudo ln -s /opt/lampp/bin/php-5.3.8 /usr/bin/php should create a symlink to the executable that exists within /usr/bin, and should allow you to call 'php' from the command line without making an /etc/init.d/ entry.

share|improve this answer
That worked but can you explain what is the difference between creating symlink on each folder? – Gerep Jun 5 '12 at 16:53
The way that executable names get run in Bash (or ZSH, or others) is based upon there being either a link or an executable in a folder that is specified in $PATH (btw, please add that to your question's content, see comment to the question). When such executables do not exist in a folder specified in $PATH, you have to use the entire path to the executable to work. By adding that sym link to /usr/bin, the system then recognizes php alone as a command/program. When in the program's folder, though, ./progname: ./ = currentdir, progname = program/executable; Run progname from here. – Thomas Ward Jun 5 '12 at 16:56
ah, well that's different. Let me (for future reference) point you to the FAQ: This is not the right place for: Linux Mint, Backtrack, and other Linux distributions (try our friends at Unix & Linux Stack Exchange). Ask on U&L in future given that Mint isnt supported here. MODS: Do not move this from Ask Ubuntu please, it does have relevance here even though the OS being used is Mint (this is common in non-apt installed software in all debian distros, so it does have relevence to Ubuntu). – Thomas Ward Jun 5 '12 at 17:02
$PATH points to where executables are, so the lack of a $PATH doesn't really mean much (since /bin and /usr/bin are both defaults for binaries). – Thomas Ward Jun 5 '12 at 17:03
This is because of the file system hierarchy standard which describes where resources and executables have to be placed in the file system. Instead of /usr/bin recommended locations are /usr/local/bin or ~/bin . – LiveWireBT Jun 5 '12 at 17:15

Not the answer you're looking for? Browse other questions tagged or ask your own question.