2

I want to see where PHP is, because I've found it in /etc/php5/apache2/php.ini., And it's not there. I do not know which is the best way to install it, since I never did it, and I did not want to put it in the wrong place, that is why I come to you. Thank you.

0

If you're using php5 in 18.04 then you won't be able to do it via

apt-get install php

since that installs php 7.2. If you're fine with that, then you're set. If you require php 5.6, you'll have to use ondrej/php repo which is outside of a default ubuntu repo. You can do that by adding the ppa:ondrej/php repo and then install php5.6. It should look something like this

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php5.6

If you're suspecting php already is installed on the server, then you can do a few things to figure that out. This will show you what version is installed.

php --version

If you get a command not found, then chances are it is not installed. If it comes back with a version and you want to see where the bin is then you can run this to find it

which php

and that will give you the path to the file it's using. If you need to find if it's installed via apt (standard way to install)

sudo apt list --installed | grep php

and that will list all packages installed with php in their name.

| improve this answer | |
  • 3
    Please note. From Dec 31st, PHP 5.6 will not receive any security fixes. Using it will pose a severe risk. I would not recommend installing it to start new projects, and you should start now migrating old projects. – pLumo Oct 16 '18 at 13:59
  • 1
    Good catch @RoVo. I just saw in their example it was specifically utilizing the php5 instance in apache, so I wanted to include a solution in case that was a requirement on their end. Definitely want to consider migrating off that if it's still a requirement. – SteamerJ Oct 16 '18 at 14:04
  • Thanks @SteamerJ, when executing: sudo apt list --installed | grep php Returns: WARNING: apt does not have a stable CLI interface. Use with caution in scripts. That wants to say, what should I do with the installation as you show me in your answer? Do I install 5.6 or directly sudo apt-get install php ? – Miguel Espeso Oct 16 '18 at 14:22
  • 1
    That warning is fine, but if you didn't get any output of packages after the warning, php is not installed. Do you know what version of PHP you need? As @RoVo mentioned, you should avoid 5.6 unless you have a specific requirement for it as it is old and will be unsupported by end of this year. If you don't have a requirement on PHP version then just the sudo apt-get install php will suffice. You will probably need to also install the libapache2-mod-php package for the easiest setup of PHP in Apache. sudo apt-get install libapache2-mod-php – SteamerJ Oct 16 '18 at 14:32
  • 1
    You can do them all at once sudo apt-get install php libapache2-mod-php – SteamerJ Oct 16 '18 at 15:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.