Categories

See More
Popular Forum

MBA (4887) B.Tech (1769) Engineering (1486) Class 12 (1030) Study Abroad (1004) Computer Science and Engineering (988) Business Management Studies (865) BBA (846) Diploma (746) CAT (651) B.Com (648) B.Sc (643) JEE Mains (618) Mechanical Engineering (574) Exam (525) India (462) Career (452) All Time Q&A (439) Mass Communication (427) BCA (417) Science (384) Computers & IT (Non-Engg) (383) Medicine & Health Sciences (381) Hotel Management (373) Civil Engineering (353) MCA (349) Tuteehub Top Questions (348) Distance (340) Colleges in India (334)
See More

Force Ubuntu to identify LAMP php installation

General Tech Bugs & Fixes

Max. 2000 characters
Tuteehub
Replies

usr_profile.png

User

( 6 months 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?

usr_profile.png

User

( 6 months 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.

what's your interest


forum_ban8_5d8c5fd7cf6f7.gif