7 install PHP in CentOS 7

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

  • Go to “Terminal” in any convenient way, for example by running it through the icon in the menu.
  • Initially add a repository Extra Packages for Enterprise Linux by entering the command sudo rpm-Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm and press Enter.
  • Because the actions are executed from the superuser, you will need to confirm the authenticity of the account, specifying the password.
  • When you finish adding new packages install another vault — Remi — through the line 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:

  • View the list of available repositories using the Remi standard command lsby typing ls /etc/yum.repos.d/remi*. Other properties used by the utilities offer to meet in a separate our material on.
  • In separate lines of the console you will see that multiple versions of PHP. For example, PHP 7.1 and 7.2. Will only switch to the most suitable one.
  • To do this, click to edit the repository that you want to activate by running the configuration file using any convenient text editor, such as vi or nano. The input string will gain approximately like this: 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.
  • In the file find section [remi-php00], where 00 is the version of PHP, and change the value “enabled” to 1.
  • To save the changes, press the key combination Ctrl + O.
  • In the file name for recording no changes are necessary, just click to Enter.
  • The exit is via Ctrl + X.
  • 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.

  • If you have already installed the previous PHP version will only update the system libraries using sudo yum update.
  • Requests to install new package, select yto confirm the action.
  • If the computer has never been installed version of PHP, need to type sudo yum install php php-fpm php-gd php-mysql.
  • The installation packages should also be verified, specifying the correct option.
  • 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.

    Source: lumpics.ru

    (Visited 33 times, 1 visits today)