Install PHP 7.3 & Using PHP's Built-In Web Server

https://www.rosehosting.com/blog/how-to-install-php-7-3-on-ubuntu-16-04

video: https://www.youtube.com/watch?v=a0RK9rGvlzo

$sudo nano /var/www/html/index.php
// content index.php => <?php phpinfo() ?>
$php -S localhost:8080 -t /home/lionel/public_html/router.php
:)))

Step 3: Install Ondřej Surý’s PPA repository

We will use the Ondřej Surý’s PPA to install PHP 7.3 version, so install the software-properties-common and python-software-properties packages:

apt install software-properties-common python-software-properties

After the installation is complete, add the Ondřej PPA:

LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php

and then update your sources:

apt update

Step 4: Install PHP 7.3

We can install PHP 7.3 with the following command:

apt install php7.3 php7.3-cli php7.3-common

To check if PHP 7.3 is installed on your server, use the command below:

php -v

Output:

PHP 7.3.0-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Dec 6 2018 20:24:27) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.0-dev, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.0-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

Step 5: Install specific PHP 7.3 extensions

If you want to install a specific module for PHP 7.3, you can search with this command:

apt-cache search php7.3

Or, if you want to check all the PHP modules available in Ubuntu, run:

apt-cache search --names-only ^php

You can find the command below useful if you want to install the most frequently used PHP modules.

apt install php-pear php7.3-curl php7.3-dev php7.3-gd php7.3-mbstring php7.3-zip php7.3-mysql php7.3-xml php7.3-fpm libapache2-mod-php7.3 php7.3-imagick php7.3-recode php7.3-tidy php7.3-xmlrpc php7.3-intl

Step 6: Change the PHP version

In this step from our article, we will show you how you can change which version of PHP to be the default if you have multiple versions of PHP installed on your Ubuntu server.

To set PHP 7.0 as the default, run:

update-alternatives --set php /usr/bin/php7.0

To set PHP 7.2 as the default, run:

update-alternatives --set php /usr/bin/php7.2

To set PHP 7.3 as the default, run:

update-alternatives --set php /usr/bin/php7.3

Before we can configure Apache to use PHP 7.3, we need to disable the old version of PHP 7.0 by typing:

a2dismod php7.0

Now enable the newly installed PHP 7.3 version with the following command:

a2enmod php7.3

Restart the Apache web server for the changes to take effect:

systemctl restart apache2

Step 7: Test and verify your PHP version

We can test the PHP version, Apache PHP and PHP modules with a simple PHP info file. We can create a phpinfo.php file in the web server default directory and access it with your server IP address on your favorite browser. In our example, we are using Apache web server so the default directory is located at /var/www/html/ .

nano /var/www/html/phpinfo.php

Add the following code to it:

<?php phpinfo(); ?>

Open the ‘phpinfo.php’ file using a web browser:

http://<ip_address>/phpinfo.php or http://<your_domain.com>/phpinfo.php

You should be able to view the current information about PHP on your server.

Last updated