Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have XAMPP installed and my PHP is:

/opt/lampp/bin/php-5.3.8

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
    
include the output of echo $PATH please –  Thomas W. Jun 5 '12 at 16:49
1  
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
add comment

closed as off topic by Thomas W., Mitch, Eliah Kagan, hbdgaf, 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.

1 Answer

up vote 5 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
1  
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 W. Jun 5 '12 at 16:56
1  
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 W. Jun 5 '12 at 17:02
1  
$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 W. Jun 5 '12 at 17:03
1  
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
show 4 more comments

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