PHP and its related components are among the most common elements in web servers. This guide uses an Ubuntu 18.04 cloud server as an example to illustrate the installation process for PHP 7.2.
First, update the Ubuntu operating system.
sudo apt-get update -y
sudo apt-get upgrade -y
For the web server, you can choose between Apache or Nginx – select one of them.
Install and start Apache.
sudo apt-get install apache2 -y
sudo systemctl start apache2.service
Install and start Nginx.
sudo apt-get install nginx -y
sudo systemctl start nginx.service
Install PHP and its components.
sudo apt-get install php -y
sudo apt-get install php-{bcmath,bz2,intl,gd,mbstring,mysql,zip,fpm} -y
Restart Apache to apply the changes.
systemctl restart apache2.service
Restart Nginx to apply the changes.
systemctl restart nginx.service
Verify the PHP version.
php -v
PHP 7.2.10-0ubuntu0.18.04.1 (cli) (built: Sep 13 2018 13:45:02) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.10-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies
The configuration file for PHP 7.2 is located at: /etc/php/7.2/fpm/php.ini. We can modify the configuration using the vi command. Remember, after making changes, it is necessary to restart the web server for them to take effect.
sudo vi /etc/php/7.2/fpm/php.ini
With these steps, you have successfully installed PHP 7.2 on an Ubuntu 18.04 cloud server, and you are now ready to deploy applications.
23-02-2024 02:02:07
22-02-2024 03:19:32
22-02-2024 03:16:03
22-02-2024 03:14:03
22-02-2024 03:11:58