{"id":2775,"date":"2018-10-22T21:34:42","date_gmt":"2018-10-22T16:04:42","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=2775"},"modified":"2026-09-29T12:52:40","modified_gmt":"2026-09-29T07:22:40","slug":"how-to-install-php-7-x-on-centos-7","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/how-to-install-php-7-x-on-centos-7\/","title":{"rendered":"How to Install PHP 7.x on CentOS 7"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>Post Date: <\/strong>October 22, 2018 <br><strong>Last Updated:<\/strong> September 29, 2026<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This guide explains how to install PHP on CentOS 7 using a third-party YUM repository, since CentOS 7&#8217;s default repos only ship an older PHP version.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Two important updates from the original version of this guide: the <strong>Webtatic repository has been discontinued<\/strong> and its packages are no longer maintained or reliably available, so this guide now uses the <strong>Remi repository<\/strong> instead, which remains actively maintained. It&#8217;s also worth knowing that <strong>CentOS 7 itself reached end-of-life in June 2024<\/strong> \u2014 if you&#8217;re setting up a new server today, consider AlmaLinux, Rocky Linux, or CentOS Stream instead, all of which continue to receive updates.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>CentOS 7 (or a compatible EL7-based distribution)<\/li>\n\n\n\n<li>Root or sudo access<\/li>\n\n\n\n<li>Apache installed (if you plan to serve PHP through it)<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Architecture<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>CentOS 7&#8217;s default repos only include an older PHP version<\/li>\n\n\n\n<li>A third-party repo (Remi) provides <strong>precompiled, newer PHP packages<\/strong> for CentOS\/RHEL<\/li>\n\n\n\n<li>Once enabled, <code>yum<\/code> treats the new PHP version like any other package \u2014 installable, updatable, and removable through the normal package manager<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2018\/10\/ChatGPT-Image-Sep-29-2026-12_48_45-PM.png\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"683\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2018\/10\/ChatGPT-Image-Sep-29-2026-12_48_45-PM-1024x683.png\" alt=\"\" class=\"wp-image-12014\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2018\/10\/ChatGPT-Image-Sep-29-2026-12_48_45-PM-1024x683.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2018\/10\/ChatGPT-Image-Sep-29-2026-12_48_45-PM-300x200.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2018\/10\/ChatGPT-Image-Sep-29-2026-12_48_45-PM-768x512.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2018\/10\/ChatGPT-Image-Sep-29-2026-12_48_45-PM-272x182.png 272w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2018\/10\/ChatGPT-Image-Sep-29-2026-12_48_45-PM.png 1536w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Steps<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. Set Up the EPEL and Remi Repositories<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo yum install -y epel-release\nsudo yum install -y https:\/\/rpms.remirepo.net\/enterprise\/remi-release-7.rpm\n<\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> The original guide used the Webtatic repository, which has since been discontinued and is no longer a reliable source for PHP packages on CentOS 7. Remi&#8217;s repository remains actively maintained and is the current standard choice for this purpose.<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\">2. Install yum-utils and Enable Your PHP Version<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo yum install -y yum-utils\nsudo yum-config-manager --enable remi-php&lt;VERSION>\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace <code>&lt;VERSION&gt;<\/code> with your target PHP version&#8217;s Remi stream name (for example, <code>remi-php81<\/code> for PHP 8.1) \u2014 check <a href=\"https:\/\/blog.remirepo.net\/\" target=\"_blank\" rel=\"noopener\">Remi&#8217;s repository page<\/a> for currently available versions, since older PHP branches eventually stop receiving new releases even within Remi&#8217;s repo.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. Install PHP and Common Extensions<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo yum install -y php php-cli php-common php-gd php-mbstring php-mysqlnd php-xml\n<\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> The original package list included <code>php71w-mcrypt<\/code>. The <code>mcrypt<\/code> extension is deprecated and was removed from PHP core years ago \u2014 skip it, and use PHP&#8217;s built-in OpenSSL functions for encryption instead if your application needs them.<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\">4. Configure PHP<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo cp \/etc\/php.ini \/etc\/php.ini.bak\nsudo vi \/etc\/php.ini\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Always back up the original file before editing, as shown above, so you have something to roll back to if a change causes issues.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5. Restart Your Web Server<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl restart httpd.service\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">6. Verify<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">php -v\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Confirm the version shown matches what you installed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Installing PHP on CentOS 7 today means going through the Remi repository rather than Webtatic, which is no longer maintained. The process itself is the same shape as before \u2014 enable the repo, install the packages, configure <code>php.ini<\/code>, restart your web server \u2014 just with a currently supported source and PHP version.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently Asked Questions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Why did the original Webtatic instructions stop working?<\/strong> The Webtatic repository was discontinued, so its packages are no longer being updated or reliably served, which is why this guide now uses Remi instead.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Should I still be using CentOS 7?<\/strong> CentOS 7 reached end-of-life in June 2024 and no longer receives security updates. For a new deployment, AlmaLinux or Rocky Linux (both CentOS-compatible) are the more durable choice.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Can I install multiple PHP versions side by side with Remi?<\/strong> To some extent \u2014 Remi provides separate streams for different PHP versions, but running multiple versions simultaneously typically requires using software collections (SCL) packages rather than the standard <code>php<\/code> package name used in this guide.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related Articles<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/using-php-and-cron-to-automate-kannel-status-monitoring\/\" target=\"_blank\" rel=\"noreferrer noopener\">Using PHP and Cron to Automate Kannel Status Monitoring<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/managing-multiple-php-versions-on-ubuntu-using-apt\/\" target=\"_blank\" rel=\"noreferrer noopener\">Managing Multiple PHP Versions on Ubuntu Using APT<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Talk to Our Technology Experts<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Setting up or migrating a CentOS-based server? Our team can help with server configuration, PHP environment setup, and OS migration planning.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/contact\">Connect with our technology experts.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Post Date: October 22, 2018 Last Updated: September 29, 2026 Introduction This guide explains how to install PHP on CentOS [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022],"tags":[161],"class_list":["post-2775","post","type-post","status-publish","format-standard","hentry","category-web-architecture","tag-centos","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-IL","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2775","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=2775"}],"version-history":[{"count":1,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2775\/revisions"}],"predecessor-version":[{"id":12015,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2775\/revisions\/12015"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=2775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=2775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=2775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}