PHP — scripted programming language which is installed by default along with the other standard components of the operating system is CentOS 7. However, the updates for this platform come quite rarely, so users are forced to work with old PHP version 5. New build of PHP 7 will only be available after a standalone download suitable repositories and further install all the libraries. In today’s article, we step by step and in detail as possible will try to describe this process.
7 install PHP in CentOS 7
As the majority of the software in CentOS, PHP 7 is installed by entering the corresponding commands in the classic console. The user does not require knowledge of how each of the algorithms, as you will need to enter these lines in “the Terminal”. We break down the procedure into steps to simplify the task for inexperienced users. Let’s start with the first action.
Step 1: Add required repository
All components of PHP 7 are stored in two repositories that have no default operating system of CentOS 7. The user needs to add them yourself, making sure you have an active connection to the Internet.
I want to draw the attention of those users who have installed on your computer phpMyAdmin. During this procedure, as discussed below, the repository is also added, so you can skip this step. Detailed instructions for installation of phpMyAdmin look for it in our other article on the following link, and we proceed to adding libraries to the OS.
Read more: Installing phpMyAdmin in CentOS 7
sudo rpm-Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpmand press Enter.
sudo rpm-Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm.
When prompted to confirm the addition of new files always agree with this, choosing the answer y. In addition, we recommend carefully reading displayed in the console text: sometimes it indicates a specific error occurs. Timely detection and correction will help to avoid problems in the future.
Step 2: Activation PHP 7
The creators of the Remi repository claim that it is necessary to add packages based on the RPM system. This includes scripted programming language PHP. After completing the first step in CentOS 7 should be available multiple versions of PHP, therefore, need to switch to the latest:
ls /etc/yum.repos.d/remi*. Other properties used by the utilities offer to meet in a separate our material on.
sudo vi /etc/yum.repos.d/remi-php71.repo, where vi is the editor used, and
/etc/yum.repos.d/remi-php71.repo— the path to the configuration file.
[remi-php00], where 00 is the version of PHP, and change the value “enabled” to
I note that above, we recommend the text editor nano. By default it is not present in the system, but added with just one command
sudo yum install nano. In some cases, this decision will be much easier vi.
Step 3: Install PHP 7
Add and activate all components are successfully completed, it remains only to compile directly to PHP 7, so you can start working with this programming language. This is done by typing in the appropriate console commands.
sudo yum update.
sudo yum install php php-fpm php-gd php-mysql.
Check the version of PHP is available at any time by entering the command
php00 -v or
php00 -r "phpinfo();" | grep "PHP Version", where the 00 in both cases a suitable version of PHP.
This completes the installation completed successfully. Note that switching to the new version — mandatory process. Additionally you need to restart your web server, if any, but it doesn’t concern Apache. For Nginx you must enter
sudo systemctl restart php-fpm.