Fri. Oct 15th, 2021

You’re going to like this one. So do you just want the damn command so you can move on without having to read more than this sentence? M’Kay, here ya go:

                 

What? you can’t read that? Maybe you have some off colors or something in your html CSS w3 #ZXXI03 thingamajiggy. Just kidding lol. There’s nothing there. If you’ve been following along or have read any of my other articles, then you know I’m usually running Ubuntu Linux 20.04 LTS. So, the reason there’s nothing above up there, something akin to:

  • apt install php

is because Ubuntu 20.04 already has the right version of PHP installed on it for most intents and purposes. In my case, or any Ubuntu 20.04 that version would be PHP v7.4. You may quickly confirm that by doing:

  • cooldude@coolserver:/var/log$ cd /etc/php ; ls -l
  • total 4
  • drwxr-xr-x 5 root root 4096 Dec 14 2020 7.4
  • cooldude@coolserver:/etc/php$

If you are able to quickly internalize that, nice. If not, that first line, ‘cd /etc/php; ls -l‘ changes your directory to the /etc/php directory and then lists it in Unix/Linux long format. I used a semicolon to string the two commands one after the other. If you don’t recognize that, I *highly* suggest reading an introductory text on the Linux command line.

Now I could end this article right there, but that would be a super minimalist non-geeky way to do it so I will geek out and move on to some details which may or may not be important to you.

I’m painfully aware that not everyone runs Ubuntu 20.04 or uses PHP 7.4. This may be for legacy reasons, it may be because it breaks code, or it could be that some people don’t like the numbers seven and four. If you take a quick look at the picture (btw, attributions to MAGEPSYCHO for the picture, which I snagged off the internet with a Google search) I used for this article you will see PHP has gone through and has a few different working versions. In fact when you change to the /etc/php directory you may see more than a single version in there, maybe version 5.6, version 7.0, who knows.

If for whatever reason you do need to use a different version of PHP, please seek out the many tutorials that are already out there in the wild which you will be able to easily locate with some Googling. The only reason I currently see needing to say run PHP version 5.3 is because you may be running an older version of Ubuntu, like 12.04, or maybe it’s application specific. If I recall correctly, I believe Ubuntu versions prior to 16.04 (maybe 18.04, not sure without looking it up) are incompatible with current PHP versions. To that I say upgrade your OS, but again, this may not be possible due to several reasons.

The final thing I want to say about PHP is that when I personally install PHP, I make sure to install the following libraries or extensions as well because with all the different items I encounter when interacting with PHP, especially when interacting with Apache 2, the primary place where PHP is utilized, at least in my setups, regardless of the PHP version. So without further ado, here are the extra libraries I almost always install:

  • sudo apt install php-common php-opcache php-cli php-gd php-curl php-mysql php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip

I’ll additionally add the following locations, as if you need to edit the options in the php.ini file under Ubuntu, you can find all that located:

  • /etc/php/7.4/apache2/php.ini
  • /etc/php/7.4/cli/php.ini
  • /usr/lib/php/7.4/php.ini-development
  • /usr/lib/php/7.4/php.ini-production
  • /usr/lib/php/7.4/php.ini-production.cli

The development and production stuff you more likely than not won’t need to interact with but if you need for example larger limits for file uploads when running some PHP program under Apache, like WordPress, the php.ini file is where you would make those changes.

Please notify me by email or by leaving a comment if there are any errors and I will correct or re-educate myself as necessary.

Please visit my Patreon page if you’re so inclined or make a donation. Or you can click the coffee cup in the bottom right corner of the screen and Buy Me A Coffee. Thank you!

By editor

Leave a Reply