I have Xubuntu installation and XAMPP installed on my PC, and everything works great. However, lately I am experimenting a little bit with Laravel framework and a lot of tutorials and people just use PHP command in terminal, but for me to work I have to load a full path like:


And the file in bin/php links to proper PHP version.

That works but I would like to speed up a process a bit and to use just php as everyone else use and it's much simpler than to use full path.

So my question is how to set a path so I can use just php in my terminal.

I have read a couple tutorials and there are suggests of setting a path in ~/.bashrc or to use export.

But none of them works for me.

Any suggestions?

3 Answers 3


Have you tried symlinking the php binary from /usr/bin?

Assume your XAMPP installation is in default location /opt/lampp

This is the command to achieve that (in your case):

sudo ln -s /opt/lampp/bin/php /usr/bin/php
  • I am getting this: ln: failed to create symbolic link '/usr/bin/php': File exists Feb 10, 2018 at 18:41
  • 1
    @Chester remove the file and link again : sudo rm /usr/bin/php then ln -s /opt/lampp/bin/php /usr/bin/php again
    – Goba
    Mar 16, 2018 at 10:01

Try sym-linking the PHP library from file and refer to this php file path /usr/bin/php wherever required.

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

Try installing the php-cli package:

sudo apt install php-cli

If you already have PHP CLI installed, you have to use update-alternatives to set the system default.

sudo update-alternatives --config php

You must log in to answer this question.

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