Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Command, not found

Tags:

bash

php

I tried to install composer via PHP command like said in getcomposer site,
But the bash throw an error:

 bash: php: command not found

So I did a search in google , and I came up with some answers, 1) to add php binary file path to $PATH variable
The problem is when I run:

 find / -name php -type f

I get this error:

find: ‘/run/user/1000/gvfs’: Permission denied

Even with sudo and as a root

2) To install tht php-cli package, so I run

 pacman -S php7-cli

But I get this error:

error: target not found: php7-cli

So what it isn't working for me?

I installed php via XAMPP installer and I', using manjaro

like image 353
Nati V Avatar asked Mar 24 '17 21:03

Nati V


2 Answers

Whenever you install XAMPP, you get all of the Apache, MySQL, PHP stack. The problem is, XAMPP won't link binaries to your PATH, because your could have another version of that software already installed.

Composer needs a PHP version available on your PATH, so the easier option is to link your already installed version of PHP.

I think you can find your PHP binary in /opt/lamp/bin so you can link it this way:

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

Hope it works!

If you want to double check your PHP binary location you can go to files then at the end you can find "other locations" click it and then go and check it.

like image 75
fedeisas Avatar answered Oct 10 '22 15:10

fedeisas


You may be mixing up linux distributions.

php-cli is, I believe from debian-based distributions.

If you are using manjaro, check this wiki page for how to install php:

https://wiki.archlinux.org/index.php/PHP

Note that arch linux and manjaro are rolling releases, so it will install php7. Many things you find on the web are for lower versions, so be careful!

like image 25
transient_loop Avatar answered Oct 10 '22 15:10

transient_loop