PHP is a server side scripting language used for web development. In this tutorial, we will show you how to install PHP 7 on a Linux VPS.
PHP 7 comes with many new and improved features. One of the most notable is the new version of Zend Engine. In addition, there are other important improvements that improve performance and significantly reduce memory usage. So PHP 7 can be twice as fast as PHP 5.6.
To install PHP 7 on a CentOS VPS, you need to login to your server via SSH. Once you are logged in, update all system software to the latest version using the following command:
Once your system updates are complete, you can go ahead and add the required yum repositories.
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
Now install PHP 7 with the following command:
yum install php70w
The installation should take a few minutes. After it is complete, you can check that the latest stable release of PHP 7 is installed on your system using the command:
You should see something like this:
PHP 7.0.0 (cli) (built: Dec 2 2015 20:42:32) ( NTS ) Copyright (c) 1997-2015 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
If you want to find all available modules in PHP 7, you can use the command:
yum search php70w
To install specific PHP 7 modules, as a module that allows PHP applications to use MySQL databases, you can use the command below:
yum install php70w-mysql
To test if PHP 7 is working on your CentOS VPS, you can create a simple PHP info file and place it in your web server’s document root. Navigate to the document root of your web server:
Create PHP info file using nano:
Paste the following content into this file:
<?php phpinfo(); ?>
Save the file and close it. Also, change the owner of the file and make Apache the owner of that file:
chown apache: info.php
Remember to restart the Apache web server if you haven’t restarted it yet for the installation changes to take effect:
systemctl restart httpd
The last one is to access the file using a web browser. Open your web browser and go to the following address:
Of course, we only use the IP address 22.214.171.124 for testing purposes, so you must make sure you are using the IP address of your actual server. You should see a page with current information such as PHP versions, compilation options, extensions, loaded config files, etc.
PS. If you liked this post, please share it with your friends on social networks using the buttons on the left or just leave an answer below. Thank you.