{"id":278,"date":"2019-05-31T16:05:55","date_gmt":"2019-05-31T16:05:55","guid":{"rendered":"https:\/\/howto.ciscoar.com\/?page_id=278"},"modified":"2020-04-26T01:24:59","modified_gmt":"2020-04-26T01:24:59","slug":"installing-php","status":"publish","type":"page","link":"https:\/\/lamp.ciscoar.com\/?page_id=278","title":{"rendered":"Installing PHP"},"content":{"rendered":"\n\n\n<h2 class=\"wp-block-heading\">Installing PHP on Linux CentOS 7<\/h2>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/php-logo.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/php-logo.png\" alt=\"\" class=\"wp-image-1400\" width=\"200\" height=\"106\"\/><\/a><\/figure><\/div>\n\n\n\n<p>To install&nbsp;<strong>PHP 7<\/strong>, you have to install and enable&nbsp;<strong>EPEL<\/strong>&nbsp;and&nbsp;<strong>Remi<\/strong>&nbsp;repositories on your CentOS 7 <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">EPEL &amp; REMI<\/h2>\n\n\n\n<p><strong>EPEL<\/strong> ( Extra Packages for Enterprise Linux&nbsp; ) and <strong>REMI<\/strong> are just two between several useful yum repositories for <strong>RHEL<\/strong> (Red Hat Enterprise Linux) based systems.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>EPEL<\/li><li>REMI<\/li><li>RPMFusin<\/li><li>ELRepo<\/li><li>Webtatic<\/li><\/ul>\n\n\n\n<p>We need they to keep our systems up to date with latest packages, because these repositories having most of the RPMs required for our servers.<\/p>\n\n\n\n<p>These repositories are  created, maintained, and managed by Linux&#8217;s professional programmers, just as an example, the following GitHub link belongs to the creator or REMI repository:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/github.com\/remicollet\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"remi (GitHub) (opens in a new tab)\">remi (GitHub)<\/a><\/li><\/ul>\n\n\n\n<p>Some packages are included in the repositories that are con\ufb01gured when the operating system is installed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to install EPEL<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"vim\" class=\"language-vim\">yum install https:\/\/dl.fedoraproject.org\/pub\/epel\/epel-release-latest-7.noarch.rpm<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">How to find EPEL files<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"vim\" class=\"language-vim\">find \/ -name \"epel*repo\"<\/code><\/pre>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/find-centos-linux-epel-repo-v2.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/find-centos-linux-epel-repo-v2.jpg\" alt=\"\" class=\"wp-image-1104\" width=\"530\" height=\"158\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/find-centos-linux-epel-repo-v2.jpg 530w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/find-centos-linux-epel-repo-v2-300x89.jpg 300w\" sizes=\"auto, (max-width: 530px) 100vw, 530px\" \/><\/a><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">How to install REMI<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"vim\" class=\"language-vim\">yum install http:\/\/rpms.remirepo.net\/enterprise\/remi-release-7.rpm<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">How to find REMI files<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"vim\" class=\"language-vim\">find \/ -name \"remi*repo\"<\/code><\/pre>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/find-centos-linux-remi-repo-v2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/find-centos-linux-remi-repo-v2.png\" alt=\"\" class=\"wp-image-1101\" width=\"546\" height=\"305\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/find-centos-linux-remi-repo-v2.png 546w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2019\/08\/find-centos-linux-remi-repo-v2-300x168.png 300w\" sizes=\"auto, (max-width: 546px) 100vw, 546px\" \/><\/a><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">YUM<\/h2>\n\n\n\n<p><strong>YUM<\/strong>&nbsp;( Yellowdog Updater, Modified ) is a command-line package management utility for RPM-based Linux systems.<\/p>\n\n\n\n<p>Yum is useful for RPMs which have dependencies, Yum searches for all dependencies of any RPM in all available repositories. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">YUM Utils<\/h2>\n\n\n\n<p>Yum Utils is a collection of useful programs for managing yum repositories and packages. Its main purpose is to extend yum\u2019s default features. <\/p>\n\n\n\n<p>Sysadmins often use It for managing (enabling or disabling) yum repositories as well as packages without having to do any manual configuration.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to install Yum-config-manager <\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"vim\" class=\"language-vim\">yum install yum-utils<\/code><\/pre>\n\n\n\n<p>One of the programs provided by yum-utils is <strong>yum-config-manager<\/strong>, which you can use to <strong>enable Remi repository<\/strong> as the default repository for installing different PHP versions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to use Yum-config-manager<\/h2>\n\n\n\n<p>We already saw with the command &#8220;find&#8221; that our system has several PHP versions inside the REMI folder, we can then choose one of them and enable it using the yum-config-manager, as shown below:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"vim\" class=\"language-vim\">yum-config-manager --enable remi-php73<\/code><\/pre>\n\n\n\n<p>Basically, whatever is inside REMI can be enabled using the above command, see below image, you already have multiple versions of PHP ready to be enabled.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/03\/enable-php-version73.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"568\" height=\"280\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/03\/enable-php-version73.jpg\" alt=\"\" class=\"wp-image-4021\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/03\/enable-php-version73.jpg 568w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/03\/enable-php-version73-300x148.jpg 300w\" sizes=\"auto, (max-width: 568px) 100vw, 568px\" \/><\/a><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Installing PHP along with its modules<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"vim\" class=\"language-vim\">yum install php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo <\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">PHP version<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"vim\" class=\"language-vim\">php -v<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"vim\" class=\"language-vim\">[root@centos7 ~]# php -v\nPHP 7.3.15 (cli) (built: Feb 18 2020 09:25:23) ( NTS )\nCopyright (c) 1997-2018 The PHP Group\nZend Engine v3.3.15, Copyright (c) 1998-2018 Zend Technologies\n[root@centos7 ~]# <\/code><\/pre>\n\n\n\n<p>This procedure can be followed either for installing PHP for the first time and also to upgrade PHP to a newer version.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Test PHP using the phpinfo() function<\/h2>\n\n\n\n<p>The phpinfo() function is a built-in function that can be used to show configuration details, installed modules, etc.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">&lt;?php\n phpinfo();\n?><\/code><\/pre>\n\n\n\n<p>You can create a simple file including this function and <strong>delete it<\/strong> immediately after you saw all the PHP information displayed via html page.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/03\/PHP-test-function-phpinfo-01.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"501\" height=\"203\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/03\/PHP-test-function-phpinfo-01.jpg\" alt=\"\" class=\"wp-image-4103\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/03\/PHP-test-function-phpinfo-01.jpg 501w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/03\/PHP-test-function-phpinfo-01-300x122.jpg 300w\" sizes=\"auto, (max-width: 501px) 100vw, 501px\" \/><\/a><figcaption>Testing PHP using the &#8220;phpinfo()&#8221; function<\/figcaption><\/figure><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"vim\" class=\"language-vim\">http:\/\/centos7.local.lab\/test.php<\/code><\/pre>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/03\/PHP-test-function-phpinfo.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1022\" height=\"821\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/03\/PHP-test-function-phpinfo.jpg\" alt=\"\" class=\"wp-image-4100\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/03\/PHP-test-function-phpinfo.jpg 1022w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/03\/PHP-test-function-phpinfo-300x241.jpg 300w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/03\/PHP-test-function-phpinfo-768x617.jpg 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/a><figcaption>Testing PHP<\/figcaption><\/figure><\/div>\n\n\n\n<p>In case the page is not loaded you can try reloading Apache.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"vim\" class=\"language-vim\">systemctl restart httpd.service<\/code><\/pre>\n\n\n\n<p>Check Apache status after the reset<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"vim\" class=\"language-vim\">systemctl status httpd.service<\/code><\/pre>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Delete the test file<\/h2>\n\n\n\n<p>Do not forget to delete the test file because it might give a hacker information they need to attack the server.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/03\/PHP-test-function-phpinfo-02.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"486\" height=\"407\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/03\/PHP-test-function-phpinfo-02.jpg\" alt=\"\" class=\"wp-image-4105\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/03\/PHP-test-function-phpinfo-02.jpg 486w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/03\/PHP-test-function-phpinfo-02-300x251.jpg 300w\" sizes=\"auto, (max-width: 486px) 100vw, 486px\" \/><\/a><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Installing PHP on Linux CentOS 7 To install&nbsp;PHP 7, you have to install and enable&nbsp;EPEL&nbsp;and&nbsp;Remi&nbsp;repositories on your CentOS 7 EPEL &amp; REMI EPEL ( Extra Packages for Enterprise Linux&nbsp; ) and REMI are just two between several useful yum repositories for RHEL (Red Hat Enterprise Linux) based systems. EPEL REMI RPMFusin ELRepo Webtatic We need &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/lamp.ciscoar.com\/?page_id=278\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Installing PHP&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-278","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/pages\/278","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=278"}],"version-history":[{"count":79,"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/pages\/278\/revisions"}],"predecessor-version":[{"id":5181,"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/pages\/278\/revisions\/5181"}],"wp:attachment":[{"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=278"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}