Force Ubuntu to identify LAMP php installation

General Tech Bugs & Fixes 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

I have installed LAMP in my ubuntu environment (16.04) which has apache, php (7.0.9), mysql...

Although the php functionality is there, when i type 'php -v' in the terminal, i get the message

The program 'php' can be found in the following packages 
* php7.0-cli 
* hhvm

which as i understand means that ubuntu does not recognise the php installation from LAMP .


Is there a way to tell ubuntu that there is a php installation in opt/lamp... in order to recognise it?

profilepic.png
manpreet 2 years ago

The message you see is triggered by a shell function called command_not_found_handle defined in your system wide bashrc (/etc/bash.bashrc). This function is called by the bash when you enter the name of a binary which is not found in the current PATH. On Ubuntu, this uses a tool called command-not-found to search your input against a package database and suggest a package that might contain the command you entered.

Depending on how you installed your LAMP stack - by using apt-get a lot or unblobbing a big tar file - there are two answers to your question.

In case you did apt-get all the stack applications you just did not install the php-cli package. In that case you can do sudo apt-get install php7.0-cli and you are fine.

In your question you mention /opt/lamp which suggests that you did the unblob-a-tar thing. This means that you should have a php cli binary somewhere in a bin directory under your /opt/lamp. What you can do is

  1. Call it using an absolute path, i.e. /opt/lamp/bin/php -v: this is perfect if you call it only now and then
  2. You can add a symlink into your bin folder, i.e ln -s /opt/lamp/bin/php /usr/bin/php: helpful if the LAMP version is the only version in your system and you use it regulary
  3. Add the path of the bin folder to your PATH environment: you might use this if the LAMP is an integral part of your system

bin/php is just an example here - your actual binary might be in a different directory under a different name. Replace it with the correct path once you found it.

If you install a full binary package in /opt it might be a good idea to check if it and if so how it uses libraries that exist in your core system. You can do this by issuing ldd /opt/lamp/bin/php and check the paths of the libs that are printed. Sometimes you get into trouble when those binaries still use your system libs but expect different versions.


0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

tuteehub community

Join Our Community Today

Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.

tuteehub community