In this tutorial, we will show you how to install PHP 7.3 on Ubuntu 18.04. PHP (Hypertext Preprocessor) is an open-source server-side scripting language designed primarily for creating dynamic interactive websites. PHP is one of the most popular languages and it is freely available for redistribution and modification. PHP powers WordPress, the most popular content management system used for blogging and building websites as well as many other e-commerce websites, customer relationship management software, enterprise resource planning software, and much more.
The latest PHP 7.3 version has been officially released on December 6th, 2018. It comes with a number of new features and a few incompatibilities that you should be aware of before upgrading from the previous version.
We have an updated version of this tutorial – How to Install PHP 8 on Ubuntu 20.04
Table of Contents
Requirements:
For the purposes of this tutorial, we will use an Ubuntu 18.04 VPS.
Full SSH root access or a user with sudo privileges is also required.
1. Getting Started
First, you will need to login to your server via SSH as the root user:
and replace “IP_ADDRESS” and “PORT_NUMBER” with your actual server IP address and SSH port number.
Once logged in, let’s make sure that your Ubuntu 18.04 server is up-to-date by running the following commands:
This will update the package index and will update the software currently installed on the server to the latest version.
Once your system is fully up to date, we can now proceed with the PHP 7.3 installation.
2. Add Ondřej Surý’s PPA repository
First, let’s install the following required packages:
After the installation is complete, add the Ondřej PPA:
Run the update command again:
3. Install PHP 7.3 on Ubuntu 18.04
We can now install PHP 7.3 on your Ubuntu 18.04 VPS.
To view the list all of all available PHP 7.3 packages, you can execute the following command:
Output:
To install PHP 7.3, together with some of the most commonly used extensions, run the following command:
To verify the installation is completed, run the following command:
The output should be similar to this:
4. Editing the PHP 7.3 settings on a Ubuntu 18.04 VPS
Next thing you may want to do is to customize the PHP 7.3 settings according to your requirements. You can do this by editing the php.ini file. To find the path to this file, you can use the command below:
It will return the path to the php.ini file which is currently loaded.
Edit the file using a text editor of your choice. We will use nano in this example.
Once you change the settings, save and close the file. If you are using Apache as a web server, you need to restart it for the new configuration to be loaded and for the changes to take effect. If you are using Nginx and PHP-FPM, you should restart the PHP-FPM service.
5. Verify if the PHP files are being executed on the server
To check if the PHP files are being executed on the server, you can create a sample info.php file and access it from your web browser.
To create the file, run the following command:
Next, enter the following content:
Save and close the file, then open your favorite web browser and access the file by using your server IP address in the URL followed by the name of the file.
You should be able to see the following information:
Congratulations. You have successfully installed PHP 7.3 on a Ubuntu 18.04 server. For more detail information about PHP 7.3, you can check the official PHP documentation.
Of course, you don’t have to install PHP 7.3 on Ubuntu 18.04 if you use one of our Managed PHP Hosting services, in which case you can simply ask our expert system administrators to install PHP 7.3 on Ubuntu 18.04 for you, using the LAMP or LEMP stack or any other web hosting stack of your choice. They are available 24×7 and will take care of your request immediately. You might want to check our post on How to Install PHP 8.0 on Ubuntu 20.04.
PS. If you liked this post, on how to install PHP 7.3 on an Ubuntu 18.04 server, please share it with your friends on the social networks using the buttons below or simply leave a comment in the comments section. Thanks.