PHP and SQL are vital to any modern website. They are not services themselves, but many services rely on them.
PHP is a general-purpose programming language that allows for creation of dynamic websites. A lot of pages that you are using implement PHP, even this one – WordPress relies heavily on it.
You also need to know that there is a necessity for a parser. A package that will allow PHP and SQL to talk to each other. Worry not, I will tell you exactly what you need to do in order for all this to work.
This one will be quite easy. Run the following
sudo apt install php php-mysql
More or less that is all you need for now. Apt will install the latest available package with all the basic modules that you need.
CAUTION note that you need to install php-mysql package as well. This is the parser that I mentioned in the introduction. It will allow PHP and MySQL to talk to each other!
After installation is finished, restart Apache with the following command
sudo service apache2 restart
Find out which version is installed
In time, you will notice that you need additional modules, if you want your services to work properly. A newly installed forum or cloud solution is going to produce an error upon initial run stating that it requires certain PHP module to run.
First of all you need to find out which version of PHP you are running. Useful tricks page contains an instruction on how to check which packages are installed on your system.
In short, run the following code
or, if you want to see all packages with php in its name
apt list --installed | grep php
The first command will show you which the version you have on your system. Short and to the point, but take a look at the second approach.
The second line will list all packages with PHP in their name that are installed on your system. Look for phpX.X string which will tell you what PHP version you have on your server. Take a look at the screenshot below. It shows that my server has php7.3 installed
Installation of additional PHP modules
Now we know what version we are running. Now let us assume a service told you that it needs CURL PHP module. The easiest way to find out which package you need to install is running the following command
axi-cache search php curl
CAUTION if you do not have xapian search engine on your server, check out how to install it here.
Result will show you all packages with PHP CURL in their name. I know it is not that of an exact instruction but install the most logical choice. In this case it would be php-curl. Remember that you can uninstall a package, if it turns out this is not the one you were looking for, and install a different one.
Now why we needed to find the version? Some packages are version specific and you need to install a compatible one. Like in the case of a zip module for PHP, which is named php7.3-zip
In short – if a package has a version number, grab the one for your version. If there is no package that contains a version number, try this one instead.
When installing new services without their perquisites they will tell you that they require new modules, packages etc. You can use the above method to find out what are the names of said packages. Check out Useful tricks page to learn more about searching for packages.
After you have installed required modules, remember to restart Apache with the following command
sudo service apache2 restart