PHP stands for Hypertext Preprocessor, free and open source, server-side scripting language that can also integrate into HTML. PHP language is suitable for dynamic and interactive web development. This is the most common and widely used web programming language in the world. PHP is an interpreted language so, you don't require a compiler to run the PHP program. PHP processing acts as a bridge between the PHP interpreter and the webserver.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customer to perform related PHP queries.
In this context, we shall look into PHP installation on Ubuntu 20.04 system.
How to perform PHP installation on Ubuntu 20.04 ?
Before proceeding with this Installation Procedure, ensure that you use a user with sudo privileges to run the administrative commands.
1. Install PHP modules
Update the apt packages of your system and then type the following command on the terminal to install PHP components:
$ sudo apt install php libapache2-mod-php php-mysql
Enter the administrative password and in a while, a prompt interrupt the installation. Press 'y' and then hit the 'Enter' key to continue this process.
After that, all PHP modules to be installed on your system. You can also install the required PHP extension depending on the project requirements.
2. Check installed PHP version
Verify the installation of PHP by running the following command:
$ php --version
The installed PHP version should display on the terminal.
3. Install required PHP extensions
To search for the relevant PHP extension type the following command on the terminal:
$ sudo apt-cache search php | grep php-
The all PHP extensions list displays on the terminal. You can find the relevant PHP extension and install it on your system by using the following syntax:
$ sudo apt install php-[extension-name]
4. Configure PHP
To configure the PHP for your web applications, you need to change certain values in the php.ini configuration file. Type the following command to open the 'php.ini' configuration file:
$ sudo nano /etc/php/7.4/apache2/php.ini
Now, find and change the following values in the configuration file:
# Upload max write = 32 M
# After max size = 48 M
# Speicher limit = 256 M
# Max perform time = 600
# Input vars = 3000
# Input time max = 1000
Once you have changed the PHP configuration settings.
Now, restart the service of the apache server by typing the following command:
$ sudo systemctl restart apache2
5. Test the PHP installation
Now, create a new PHP file in the web directory. Here, we have created a new file with the name 'info.php' by using the following command:
$ sudo nano /var/www/html/info.php
Paste the following PHP code in the above file:
echo "Welcome to PHP installation Tutorial!";
Save this file and open the following URL in your browser:
For example, 127.0.0.1/info.php
This should display the output as shown below:
Welcome to PHP installation Tutorial!
[Need urgent assistance in fixing PHP version errors? We can help you. ]