{"id":45,"date":"2025-05-16T01:27:02","date_gmt":"2025-05-15T22:27:02","guid":{"rendered":"http:\/\/localhost\/wordpress\/index.php\/2016\/03\/11\/cors-header-access-control-allow-origin-missing-in-slimangularjs-stack\/"},"modified":"2025-05-16T01:27:08","modified_gmt":"2025-05-15T22:27:08","slug":"how-to-install-php-8-on-amazon-linux","status":"publish","type":"post","link":"https:\/\/computingforgeeks.com\/how-to-install-php-8-on-amazon-linux\/","title":{"rendered":"How To Install PHP 8.1 on Amazon Linux 2"},"content":{"rendered":"\n<p><a href=\"https:\/\/computingforgeeks.com\/how-to-install-php-on-debian-linux-2\/\">PHP 8.1<\/a> was released on&nbsp;<a target=\"_blank\" href=\"https:\/\/wiki.php.net\/todo\/php81\" rel=\"noreferrer noopener\">November 25, 2021<\/a> by the PHP Development team for public use. PHP is a very popular and powerful scripting and programming language for the Web. Most web <a href=\"https:\/\/computingforgeeks.com\/install-and-use-winget-windows-package-manager-client\/\">applications<\/a> and dynamic web pages are created in PHP. Either by using vanilla PHP coding or Frameworks powered by PHP. In this guide, we shall learn how you can install PHP 8.1 on Amazon Linux 2. Amazon Linux 2 is a Linux operating system from Amazon Web Services (AWS) designed to be secure, stable and to provide high performance.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">New features in PHP 8.1?<\/h3>\n\n\n\n<p>Here is a summary of key features available in <a href=\"https:\/\/computingforgeeks.com\/how-to-install-php-centos-rhel-linux\/\">PHP 8.1<\/a> release.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Enums<\/strong>&nbsp;\u2013 They are now added in PHP 8.1<\/li>\n\n\n\n<li><strong>AVIF Image Format support&nbsp;<\/strong>\u2013 The PHP 8.1\u2019s image processing and GD extension adds support for AVIF images.<\/li>\n\n\n\n<li><strong>Readonly properties<\/strong>&nbsp;\u2013 Class properties can be marked as readonly hence can only be written once<\/li>\n\n\n\n<li><strong>Never Return Type<\/strong>&nbsp;\u2013 A new return type hint called never is added in PHP 8.1<\/li>\n\n\n\n<li>Support for DNS-over-HTTPS (DoH)<\/li>\n\n\n\n<li>PHP 8.1 adds array_is_list as a built-in function<\/li>\n\n\n\n<li><strong style=\"font-family: Verdana, BlinkMacSystemFont, -apple-system, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; color: initial;\">Added support for Fibers<\/strong><span style=\"font-family: Verdana, BlinkMacSystemFont, -apple-system, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; color: initial;\">&nbsp;\u2013 The low level mechanism to manage parallelism<\/span><\/li>\n\n\n\n<li><strong>File Uploads with CURLStringFile<\/strong>&nbsp;\u2013 In PHP 8.1, PHP Curl extension now supports HTTP(S) requests with file uploads<\/li>\n\n\n\n<li>Addition of pure intersection types feature<\/li>\n\n\n\n<li>Define final Class Constants<\/li>\n\n\n\n<li><span style=\"font-family: Verdana, BlinkMacSystemFont, -apple-system, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; color: initial;\">Explicit Octal Numeral Notation<\/span><\/li>\n\n\n\n<li>New fdatasync() and fsync() Functions<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-install-php-8-0-on-centos-8-centos-7\">How To Install PHP 8.1 on Amazon Linux 2<\/h2>\n\n\n\n<p>We&#8217;ll use Remi YUM repositories to install <meta charset=\"utf-8\">PHP 8.1 on Amazon Linux 2. The versions of PHP available in default Amazon Linux 2 are much older. Remi repository is a free and stable YUM repository mainly for the PHP stack. It contains packages for the latest versions of PHP.<\/p>\n\n\n\n<p>We&#8217;ll consider two methods of installing <meta charset=\"utf-8\">PHP 8.1 on Amazon Linux 2.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Install PHP 8.1 as main PHP version (default version)<\/li>\n\n\n\n<li>Install PHP 8.1 alongside other PHP versions (e.g 8.0 and 7.4)<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-install-php-8-0-as-default-version-only-recommended-for-ga-release\">Install PHP 8.1 on <meta charset=\"utf-8\">Amazon Linux 2 alongside other PHP versions<\/h3>\n\n\n\n<p>If you use this method to install <meta charset=\"utf-8\">PHP 8.1 on <meta charset=\"utf-8\">Amazon Linux 2, you can run more than one version of PHP at the same time.<\/p>\n\n\n\n<p>Let&#8217;s add REMI yum repository before we install PHP 8.1.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo yum -y install https:\/\/dl.fedoraproject.org\/pub\/epel\/epel-release-latest-7.noarch.rpm\nsudo yum -y install https:\/\/rpms.remirepo.net\/enterprise\/remi-release-7.rpm\nsudo yum -y install yum-utils<\/code><\/pre>\n\n\n\n<p>Confirm repository addition with the following commands:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <span class=\"has-inline-color has-luminous-vivid-amber-color\">sudo yum repolist<\/span>\n214 packages excluded due to repository priority protections\nrepo id                                                                       repo name                                                                                                      status\namzn2-core\/2\/x86_64                                                           Amazon Linux 2 core repository                                                                                     26801\namzn2extra-docker\/2\/x86_64                                                    Amazon Extras repo for docker                                                                                         55\nepel\/x86_64                                                                   Extra Packages for Enterprise Linux 7 - x86_64                                                                 13481+208\nremi-safe                                                                     Safe Remi's RPM repository for Enterprise Linux 7 - x86_64                                                        4650+6\nrepolist: 44987<\/code><\/pre>\n\n\n\n<p>Enable Remi repository for PHP 8.1<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo yum-config-manager --disable 'remi-php*'\nsudo yum-config-manager --enable remi-php81<\/code><\/pre>\n\n\n\n<p>Finally install PHP 8.1 on Amazon Linux 2 system<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo yum install php81<\/code><\/pre>\n\n\n\n<p>Sample output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>....\nTransaction Summary\n======================================================================================================================================================================================================\nInstall  1 Package (+18 Dependent packages)\n\nTotal download size: 11 M\nInstalled size: 39 M\nIs this ok &#91;y\/d\/N]: <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">y<\/mark><\/code><\/pre>\n\n\n\n<p>Checking version of PHP 8.1 installed:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <span class=\"has-inline-color has-pale-pink-color\">php81 --version<\/span>\nPHP<strong> 8.1.0 <\/strong>(cli) (built: Nov 23 2021 18:56:11) (NTS gcc x86_64)\nCopyright (c) The PHP Group\nZend Engine v4.1.0, Copyright (c) Zend Technologies<\/code><\/pre>\n\n\n\n<p>Configuration files for PHP are located in <code>\/etc\/opt\/remi\/php81\/<\/code> directory<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <span class=\"has-inline-color has-pale-pink-color\">ls -1 \/etc\/opt\/remi\/php81\/<\/span>\nX11\nopt\nphp.d\nphp.ini\npki\npm\nskel\nsysconfig\nxdg\nxinetd.d<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Install PHP 8.1 extensions on Amazon Linux 2<\/h4>\n\n\n\n<p>To install any PHP 8.1 extension, use command syntax below:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo yum install php81-php-xxx<\/code><\/pre>\n\n\n\n<p>See below example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo yum install php81-php-{cli,fpm,mysqlnd,devel,gd,mbstring,curl,xml,pear,bcmath,json,opcache,ldap}<\/code><\/pre>\n\n\n\n<p>Agree to installation prompt:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>...\nTransaction Summary\n======================================================================================================================================================================================================\nInstall  10 Packages (+48 Dependent packages)\n\nTotal download size: 62 M\nInstalled size: 187 M\nIs this ok &#91;y\/d\/N]: <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">y<\/mark><\/code><\/pre>\n\n\n\n<p>Use below commands list all PHP modules<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <span class=\"has-inline-color has-pale-pink-color\">php81 --modules<\/span>\n&#91;PHP Modules]\nbcmath\nbz2\ncalendar\nCore\nctype\ncurl\ndate\ndom\nexif\nfileinfo\nfilter\nftp\ngd\ngettext\nhash\niconv\njson\nlibxml\nmbstring\nmysqli\nmysqlnd\nopenssl\npcntl\npcre\nPDO\npdo_mysql\npdo_sqlite\nPhar\nposix\nreadline\nReflection\nsession\nshmop\nSimpleXML\nsockets\nSPL\nsqlite3\nstandard\nsysvmsg\nsysvsem\nsysvshm\ntokenizer\nxml\nxmlreader\nxmlwriter\nxsl\nZend OPcache\nzip\nzlib\n\n&#91;Zend Modules]\nZend OPcache<\/code><\/pre>\n\n\n\n<p>You now have PHP 8.1 installed on your Amazon Linux 2 system. We have provided links to important PHP websites and Forums below:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/wiki.php.net\/ideas\" target=\"_blank\" rel=\"noreferrer noopener\">Ideas to work on<\/a>&nbsp;includes ideas that people might want to work on<\/li>\n\n\n\n<li><a href=\"https:\/\/wiki.php.net\/gsoc\" target=\"_blank\" rel=\"noreferrer noopener\">Google Summer of Code<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/wiki.php.net\/platforms\" target=\"_blank\" rel=\"noreferrer noopener\">Contacts for certain supported platforms<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/wiki.php.net\/summits\" target=\"_blank\" rel=\"noreferrer noopener\">Developer Summits<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/wiki.php.net\/usergroups\" target=\"_blank\" rel=\"noreferrer noopener\">PHP User Group Information<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>PHP 8.1 was released on&nbsp;November 25, 2021 by the PHP Development team for public use. PHP is a very popular and powerful scripting and programming language for the Web. Most web applications and dynamic web pages are created in PHP. Either by using vanilla PHP coding or Frameworks powered by PHP. In this guide, we &#8230; <a title=\"How To Install PHP 8.1 on Amazon Linux 2\" class=\"read-more\" href=\"https:\/\/computingforgeeks.com\/how-to-install-php-8-on-amazon-linux\/\" aria-label=\"Read more about How To Install PHP 8.1 on Amazon Linux 2\">Read more<\/a><\/p>\n","protected":false},"author":3,"featured_media":110299,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[461,299,50],"tags":[191,36310,36415],"class_list":["post-45","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-databases","category-how-to","category-linux-tutorials","tag-php","tag-php-8-1","tag-php-8-1-on-amazon-linux-2"],"_links":{"self":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/45","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/comments?post=45"}],"version-history":[{"count":1,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/45\/revisions"}],"predecessor-version":[{"id":160037,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/45\/revisions\/160037"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media\/110299"}],"wp:attachment":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media?parent=45"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/categories?post=45"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/tags?post=45"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}