{"id":206,"date":"2015-12-09T21:59:27","date_gmt":"2015-12-10T05:59:27","guid":{"rendered":"https:\/\/cloudinsidr.com\/content\/?p=206"},"modified":"2017-11-26T16:38:41","modified_gmt":"2017-11-27T00:38:41","slug":"how-to-install-php-7-on-centos-7-red-hat-rhel-7-fedora","status":"publish","type":"post","link":"https:\/\/www.cloudinsidr.com\/content\/how-to-install-php-7-on-centos-7-red-hat-rhel-7-fedora\/","title":{"rendered":"How to Install PHP 7 on Fedora, RHEL, CentOS 7 \u2014 the Red Hat family"},"content":{"rendered":"<p>Installing PHP on the Red Hat family\u2014Fedora, RHEL, CentOS 7\u2014is a must for cyber security and it&#8217;s not rocket science. With a few easy steps, you too can bring your PHP based web applications to the next level.<\/p>\n<p><!--more--><\/p>\n<p>PHP 7\u00a0brings such profound improvements that\u00a0the lucky 7 as a version number\u00a0seems more than justified. The upgrade is easy, painless, and takes just a couple of quick steps. Here is how to do it.<\/p>\n<p>[tweet &#8220;#PHP 7.0.1 released, RPMs already available in #remirepo 4 #fedora #rhel &amp; #centos via @cloudinsidr thnx @RemiCollet&#8221;]<\/p>\n<p>RedHat has completed the transition of\u00a0<strong>RHEL\/Fedora<\/strong>\u00a0from <strong>yum<\/strong> to its next iteration,\u00a0<strong>DNF<\/strong> (dnf), short for <em>dandified yum<\/em>. It supports\u00a0<strong>RPM<\/strong>, <strong>libsolv<\/strong>, and <strong>hawkey<\/strong> libraries. DNF (which inherited some qualities from both yum and aptitude) has been released for <a href=\"http:\/\/dnf.baseurl.org\/\" target=\"_blank\" rel=\"noopener\">Fedora<\/a>\u00a0with <a href=\"http:\/\/dnf.baseurl.org\/2015\/11\/23\/fedora-useradmin-guides-are-up-to-date-for-dnf\/\" target=\"_blank\" rel=\"noopener\">user and admin guides<\/a>. Use it the way you would work with yum.<\/p>\n<p>To get your hands on a working installation of PHP 7, you can currently use either the old yum or dnf (here is the\u00a0<a href=\"http:\/\/dnf.readthedocs.org\/en\/latest\/command_ref.html\" target=\"_blank\" rel=\"noopener\">command reference<\/a>).<\/p>\n<p>In Remi&#8217;s RPM repository, PHP RPMs have been renamed php70 in order to allow installation alongside the default PHP of your CentOS\/RHEL\/Fedora (if there is one on your system). The\u00a0FPM service (php70-php-fpm) listens on the default port 9000 so it may need adjusting should another version of PHP be already running.<\/p>\n<p>Follow these steps to install PHP 7 on CentOS with php-fpm, the server API or SAPI of choice for NGINX, using the Remi repository, on\u00a0x86_64.\u00a0You must be\u00a0root\u00a0(<span class=\"lang:sh decode:true crayon-inline\">sudo su<\/span>\u00a0, otherwise prepend the relevant commands with <span class=\"lang:sh decode:true crayon-inline \">sudo<\/span>\u00a0to execute them as root).<\/p>\n<h4>Step 1. Get yourself the REMI\u00a0repo<\/h4>\n<p>Install the Remi repository (#remirepo for #fedora, #rhel and #centos) with these commands (you must be\u00a0root, see the paragraph above):<\/p>\n<pre class=\"lang:sh decode:true\" title=\"Install the Remi repository on CentOS 7\">wget http:\/\/rpms.remirepo.net\/enterprise\/remi-release-7.rpm \r\nsudo rpm -Uvh remi-release-7*.rpm<\/pre>\n<h4>\u00a0Step 2. Install PHP 7<\/h4>\n<p>Install PHP 7 from the remi repository:<\/p>\n<pre class=\"toolbar-overlay:true toolbar-delay:true lang:sh decode:true \">yum --enablerepo=remi-php70 install php70-php<\/pre>\n<h4>Step 3. Install PHP\u00a0extensions<\/h4>\n<p>Install PHP modules using\u00a0the remi repository (the example is a recommended configuration):<\/p>\n<pre class=\"toolbar-overlay:true lang:sh decode:true\">yum --enablerepo=remi-php70 install php70-php-pear php70-php-bcmath php70-php-pecl-jsond-devel php70-php-mysqlnd php70-php-gd php70-php-common php70-php-fpm php70-php-intl php70-php-cli php70-php php70-php-xml php70-php-opcache php70-php-pecl-apcu php70-php-pecl-jsond php70-php-pdo php70-php-gmp php70-php-process php70-php-pecl-imagick php70-php-devel php70-php-mbstring php70-php-mcrypt<\/pre>\n<p>To find out which other extensions are available, use search with\u00a0yum:<\/p>\n<pre class=\"lang:sh decode:true \">yum search php70<\/pre>\n<p>Speaking of extensions: ereg, mssql, sybase_ct and\u00a0mysql have been removed from PHP.<\/p>\n<p>In order to enable the remi repository only during software installation (that is: only when you need it), use the <span class=\"lang:sh decode:true crayon-inline \">&#8211;enablerepo=remi<\/span>\u00a0 option with yum. For example like this:<\/p>\n<pre class=\"lang:sh decode:true \">sudo yum --enablerepo=remi install php-tcpdf<\/pre>\n<p>To update your already installed packages using the Remi repository, you would\u00a0enter this command:<\/p>\n<pre class=\"lang:sh decode:true\">yum --enablerepo=remi update remi-release<\/pre>\n<h4>Step 4. Start PHP<\/h4>\n<p>To start PHP (once) use this command:<\/p>\n<pre class=\"toolbar-overlay:true toolbar-delay:true lang:sh decode:true\">service php70-php-fpm start<\/pre>\n<p>or<\/p>\n<pre class=\"toolbar-overlay:true toolbar-delay:true lang:sh decode:true \">systemctl start php70-php-fpm<\/pre>\n<h4>Step 5.\u00a0Enable automatic launch of PHP 7 on system startup<\/h4>\n<p>Enable automatic launch of the PHP interpreter on system startup on CentOS 7\/Red Hat\/Fedora, use this command:<\/p>\n<pre class=\"toolbar-overlay:true toolbar-delay:true lang:sh decode:true \">systemctl enable php70-php-fpm<\/pre>\n<p>The\u00a0output of this command should resemble this line:<\/p>\n<pre class=\"toolbar-overlay:true toolbar-delay:true lang:sh decode:true \">ln -s '\/usr\/lib\/systemd\/system\/php70-php-fpm.service' '\/etc\/systemd\/system\/multi-user.target.wants\/php70-php-fpm.service'<\/pre>\n<p>You can\u00a0verify the current status of PHP 7 using this command:<\/p>\n<pre class=\"toolbar-overlay:true toolbar-delay:true lang:sh decode:true\">systemctl status php70-php-fpm\r\n\r\n[root@ip-16-0-0-170 centos]# systemctl status php70-php-fpm\r\nphp70-php-fpm.service - The PHP FastCGI Process Manager\r\nLoaded: loaded (\/usr\/lib\/systemd\/system\/php70-php-fpm.service; enabled)\r\nActive: active (running) since Thu 2015-12-10 05:29:25 UTC; 2s ago\r\nMain PID: 2102 (php-fpm)\r\nStatus: \"Ready to handle connections\"\r\nCGroup: \/system.slice\/php70-php-fpm.service\r\n\u251c\u25002102 php-fpm: master process (\/etc\/opt\/remi\/php70\/php-fpm.conf)\r\n\u251c\u25002103 php-fpm: pool www\r\n\u251c\u25002104 php-fpm: pool www\r\n\u251c\u25002105 php-fpm: pool www\r\n\u251c\u25002106 php-fpm: pool www\r\n\u2514\u25002107 php-fpm: pool www\r\n\r\nDec 10 05:29:25 ip-12-3-4-170.ec2.internal systemd[1]: Started The PHP FastCGI Process Manager.<\/pre>\n<p>This output also shows you that php-fpm pools, while running, have not been configured yet.<\/p>\n<p>If you also want to set up\u00a0MySQL\/MariaDB,\u00a0you may want to read:\u00a0<a href=\"https:\/\/cloudinsidr.com\/content\/lemp-how-to-set-up-nginx-with-mariadbmysql-and-php-7-x-on-centos-7-rhelfedora\/\">High-Stakes, High-Security LEMP Setup: Nginx with MariaDB\/MySQL, and PHP 7.x on CentOS 7 (RHEL\/Fedora) with SELinux<\/a><\/p>\n<p>Subscribe to our newsletter and we will keep you up to date.<\/p>\n<hr \/>\n<p>[wysija_form id=&#8221;1&#8243;]<\/p>\n<p>Related:<\/p>\n<ul>\n<li>How to <a href=\"https:\/\/cloudinsidr.com\/content\/how-to-securely-fix-php-session-errors\/\">fix PHP sessions to ensure security\u00a0<\/a><\/li>\n<li><a href=\"https:\/\/cloudinsidr.com\/content\/how-to-figure-out-your-php-configuration-parameters-without-info-php\/\">How to check your current PHP configuration settings without exposing your server<\/a>.<\/li>\n<\/ul>\n<hr \/>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/cloudinsidr.com\/content\/wp-content\/uploads\/2015\/12\/hostedby.png\" rel=\"attachment wp-att-248\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-248 alignleft\" src=\"https:\/\/cloudinsidr.com\/content\/wp-content\/uploads\/2015\/12\/hostedby.png\" alt=\"Remi's RPM repository\" width=\"200\" height=\"143\" \/><\/a><\/p>\n<p><strong>Here is what you can do now: why don&#8217;t you visit the Amazon wishlist of <a href=\"https:\/\/twitter.com\/RemiCollet\" target=\"_blank\" rel=\"noopener\">@RemiCollet<\/a> and say Thank you:\u00a0<a href=\"http:\/\/amzn.to\/1MjuS2N\" target=\"_blank\" rel=\"noopener\">http:\/\/amzn.to\/1MjuS2N<\/a>\u00a0for compiling PHP for you! The Donations page is here: <a href=\"http:\/\/rpms.remirepo.net\/\" target=\"_blank\" rel=\"noopener\">http:\/\/rpms.remirepo.net\/<\/a><\/strong><\/p>\n<p><a title=\"Large Rectangle (336 x 280)\" href=\"https:\/\/www.thesslstore.com\/symantec.aspx?btoken=Ds82EweFB%2fXSIm6zhK8bvqBUEab%2bpo4rXpiJfosbOA0%3d\" rel=\"nofollow\"><img decoding=\"async\" src=\"https:\/\/affiliate.thesslstore.com\/Banner.ashx?token=Ds82EweFB%2fXSIm6zhK8bvqBUEab%2bpo4rXpiJfosbOA0%3d\" alt=\"Large Rectangle (336 x 280)\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Installing PHP on the Red Hat family\u2014Fedora, RHEL, CentOS 7\u2014is a must for cyber security and it&#8217;s not rocket science. With a few easy steps, you too can bring your PHP based web applications to the next level.<\/p>\n","protected":false},"author":101012,"featured_media":76,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[16,143,109,168,154,6],"tags":[52,87,54,7,50,27,55,57,56,53,51],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v14.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Install PHP 7 on Fedora, RHEL, CentOS 7 \u2014 the Red Hat family - CloudInsidr<\/title>\n<meta name=\"robots\" content=\"index, follow\" \/>\n<meta name=\"googlebot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta name=\"bingbot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.cloudinsidr.com\/content\/how-to-install-php-7-on-centos-7-red-hat-rhel-7-fedora\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Install PHP 7 on Fedora, RHEL, CentOS 7 \u2014 the Red Hat family - CloudInsidr\" \/>\n<meta property=\"og:description\" content=\"Installing PHP on the Red Hat family\u2014Fedora, RHEL, CentOS 7\u2014is a must for cyber security and it&#8217;s not rocket science. With a few easy steps, you too can bring your PHP based web applications to the next level.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.cloudinsidr.com\/content\/how-to-install-php-7-on-centos-7-red-hat-rhel-7-fedora\/\" \/>\n<meta property=\"og:site_name\" content=\"CloudInsidr\" \/>\n<meta property=\"article:published_time\" content=\"2015-12-10T05:59:27+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-11-27T00:38:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.cloudinsidr.com\/content\/wp-content\/uploads\/2015\/11\/cloudinsidr_logo_900px-wide.png\" \/>\n\t<meta property=\"og:image:width\" content=\"900\" \/>\n\t<meta property=\"og:image:height\" content=\"326\" \/>\n<meta name=\"twitter:card\" content=\"summary\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.cloudinsidr.com\/content\/#website\",\"url\":\"https:\/\/www.cloudinsidr.com\/content\/\",\"name\":\"CloudInsidr\",\"description\":\"Cyber security, infotech\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/www.cloudinsidr.com\/content\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.cloudinsidr.com\/content\/how-to-install-php-7-on-centos-7-red-hat-rhel-7-fedora\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/www.cloudinsidr.com\/content\/wp-content\/uploads\/2015\/11\/cloudinsidr_logo_900px-wide.png\",\"width\":900,\"height\":326,\"caption\":\"cloudinsidr.com logo (900px wide)\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.cloudinsidr.com\/content\/how-to-install-php-7-on-centos-7-red-hat-rhel-7-fedora\/#webpage\",\"url\":\"https:\/\/www.cloudinsidr.com\/content\/how-to-install-php-7-on-centos-7-red-hat-rhel-7-fedora\/\",\"name\":\"How to Install PHP 7 on Fedora, RHEL, CentOS 7 \\u2014 the Red Hat family - CloudInsidr\",\"isPartOf\":{\"@id\":\"https:\/\/www.cloudinsidr.com\/content\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.cloudinsidr.com\/content\/how-to-install-php-7-on-centos-7-red-hat-rhel-7-fedora\/#primaryimage\"},\"datePublished\":\"2015-12-10T05:59:27+00:00\",\"dateModified\":\"2017-11-27T00:38:41+00:00\",\"author\":{\"@id\":\"https:\/\/www.cloudinsidr.com\/content\/#\/schema\/person\/73723b2da71b6d515d17ca593ea5dc68\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.cloudinsidr.com\/content\/how-to-install-php-7-on-centos-7-red-hat-rhel-7-fedora\/\"]}]},{\"@type\":[\"Person\"],\"@id\":\"https:\/\/www.cloudinsidr.com\/content\/#\/schema\/person\/73723b2da71b6d515d17ca593ea5dc68\",\"name\":\"Filipe Martins\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.cloudinsidr.com\/content\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/dbac033b4d26da8ca1fbde233e49c8dc?s=96&d=mm&r=g\",\"caption\":\"Filipe Martins\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/posts\/206"}],"collection":[{"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/users\/101012"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/comments?post=206"}],"version-history":[{"count":40,"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/posts\/206\/revisions"}],"predecessor-version":[{"id":1769,"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/posts\/206\/revisions\/1769"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/media\/76"}],"wp:attachment":[{"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/media?parent=206"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/categories?post=206"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/tags?post=206"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}