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?

  • 1
    /etc/init.d is a place for system service related scripts. You shouldn't be making links there unless you are linking a service. Executables tend to be in /usr/bin, /usr/local/bin, etc.
    – Tim
    Jun 5, 2012 at 16:54
  • Add the directory to your PATH. And the symlink belongs to /usr/local/bin, not /etc/init.d.
    – Marco
    Jun 5, 2012 at 16:55

4 Answers 4


You should make the link in one of the folders listed in your PATH variable. Run echo $PATH to see the list of paths. Once the link is created in one of those paths, you will no longer need to prepend ./

  • where do I echo $PATH?
    – Gerep
    Jun 5, 2012 at 16:56
  • From a terminal or console... AKA the "command line"
    – Tim
    Jun 5, 2012 at 18:59

php wasn't a boot script , you should never put that in /etc/init.d

Normally you should have a symbol link named php in /opt/lampp/bin/ , which is linked to /opt/lampp/bin/php-5.3.8

(If not , do ln -s /opt/lampp/bin/php-5.3.8 /opt/lampp/bin/php to make this work)

And in your ~/.bashrc , add more path to $PATH:

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

And you execute your script like this , on any directory:

php XX.php


Make a symbolic link from the executable you want to execute by name to a location in your PATH.

ln -s ../../../opt/lampp/bin/php-5.3.8 /usr/local/bin/php

The default PATH does not contain the current directory, because it's uncommon to change to a directory containing an executable before executing it.

Don't mess up with system directories. /etc/init.d contains scripts that start and stop system services; this is not the place to put a link to an interpreter.


Make a file /etc/profile.d/php_alias.sh::

alias php='/opt/lampp/bin/php-5.3.8'

(restart bash)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .