🦸‍♂️
KT's DevOps Notes
  • Hello World
  • Misc
    • Ubuntu Setup
    • Mac Os Setup
  • Database
    • Redis
      • How To Migrate Redis Data to a DigitalOcean Managed Database
      • How To Connect to a Managed Redis Instance over TLS with Stunnel and redis-cli
    • MariaDB
      • How to Setup MariaDB Galera Cluster on Ubuntu 18.04 with HAProxy
      • How to change innodb_thread_concurrency Read/Wirte Concurrency in MySQL
      • How to change innodb_write_io_threads in MySQL
      • How to change innodb_read_io_threads in MySQL
  • OCI Foundations 2020 Associate Certification | 1Z0–1085–20 | Preparation…
  • Security
  • Ubuntu
    • Apache Server Configuration
      • Configuring Let’s Encrypt SSL Cert for Apache on Ubuntu 18.04
      • Installing Apache, MySQL, PHP (LAMP) Stack on Ubuntu 18.04
      • Installing Apache on Ubuntu 18.04 with Multiple Domains
    • Nginx Server Configuration
      • Robots.txt disallow all with nginx
      • Installing Nginx, MySQL, PHP (LEMP) Stack on Ubuntu 18.04
      • Installing Nginx on Ubuntu 18.04 with Multiple Domains
      • Configuring Let’s Encrypt SSL Cert for Nginx on Ubuntu 18.04
    • Creating Swap Space on Ubuntu 18.04
    • Dell Inspiron 7559 Ubuntu Linux Guide
    • How to configure Postfix to use Gmail SMTP on Ubuntu 18.04 & 16.04 | LeetDev
  • Setting up SSL Certificates for HAProxy with certbot
  • PHP
  • PHP / Apache: Set Max File Upload and Post Size | LeetDev
  • Upgrade centos7 openssh & openssl to the latest version
  • Downgrading to php7.3 on Amazon Linux 2
Powered by GitBook
On this page

Was this helpful?

Downgrading to php7.3 on Amazon Linux 2

PreviousUpgrade centos7 openssh & openssl to the latest version

Last updated 2 years ago

Was this helpful?

Installing an up to date version of PHP on Amazon Linux 2 is straightforward. You can follow , which makes use of the amazon-linux-extras command.

I found myself, however, in the unusual position of needing to run run an out of date version of PHP on AWS. The issue is that is developing a WordPress plugin, and this plugin must run on PHP 7.3. The standard on Amazon Linux 2 these day is PHP 7.4.

Here are the steps I went through to coax my system from PHP 7.4 down to 7.3. I hope you don't find yourself needing these instructions, but if you do, enjoy!

# Grab a list of all the PHP modules currently installed
$ rpm -qa |grep php > all.installed
$ cat all.installed
php-common-7.4.26-1.amzn2.x86_64
php-fpm-7.4.26-1.amzn2.x86_64
php-json-7.4.26-1.amzn2.x86_64
php-pdo-7.4.26-1.amzn2.x86_64
php-cli-7.4.26-1.amzn2.x86_64
php-xml-7.4.26-1.amzn2.x86_64
php-mbstring-7.4.26-1.amzn2.x86_64
php-mysqlnd-7.4.26-1.amzn2.x86_64

# The 'remi' repo offers access to specific version of PHP.
# Here, I'm installing PHP 7.3 using the remi-php73 repo.
$ sudo yum install  http://rpms.remirepo.net/enterprise/remi-release-7.rpm
$ sudo  yum-config-manager --enable remi-php73

# Bye-bye up to date version of PHP.
$ sudo yum -y remove php*
$ sudo amazon-linux-extras disable php7.4

# Hello old, crufty version of PHP.
# Note: to access PHP modules the prefix is now 'php73-'
# So php-pdo is installed as php73-php-pdo.
$ sudo yum install php73
$ sudo yum install $(cat all.installed  | grep ^php-| sed 's/-7.4.*//' | sed 's/^/php73-/')

# Properly install php73 as /usr/bin/php
$ sudo update-alternatives --install /usr/bin/php php /usr/bin/php73 10

# Enable and start the php-fpm service
$ sudo systemctl enable php73-php-fpm
$ sudo systemctl start php73-php-fpm


# Where the heck are the config files for php-fpm? Let's ask rpm.
$ rpm -ql php73-php-fpm
/etc/logrotate.d/php73-php-fpm
/etc/opt/remi/php73/php-fpm.conf
/etc/opt/remi/php73/php-fpm.d
/etc/opt/remi/php73/php-fpm.d/www.conf
/etc/opt/remi/php73/sysconfig/php-fpm
/etc/systemd/system/php73-php-fpm.service.d
/opt/remi/php73/root/usr/sbin/php-fpm
/opt/remi/php73/root/usr/share/doc/php73-php-fpm-7.3.33
/opt/remi/php73/root/usr/share/doc/php73-php-fpm-7.3.33/php-fpm.conf.default
/opt/remi/php73/root/usr/share/doc/php73-php-fpm-7.3.33/www.conf.default
/opt/remi/php73/root/usr/share/fpm
/opt/remi/php73/root/usr/share/fpm/status.html
/opt/remi/php73/root/usr/share/licenses/php73-php-fpm-7.3.33
/opt/remi/php73/root/usr/share/licenses/php73-php-fpm-7.3.33/fpm_LICENSE
/opt/remi/php73/root/usr/share/man/man8/php-fpm.8.gz
/usr/lib/systemd/system/php73-php-fpm.service
/var/opt/remi/php73/lib/php/opcache
/var/opt/remi/php73/lib/php/session
/var/opt/remi/php73/lib/php/wsdlcache
/var/opt/remi/php73/log/php-fpm
/var/opt/remi/php73/run/php-fpm

# Found it. Now, where php-fpm listening?
$ cat /etc/opt/remi/php73/php-fpm.d/www.conf |grep ^listen
listen = 127.0.0.1:9000
listen.allowed_clients = 127.0.0.1

# Use this info to create /etc/httpd/conf.d/php.conf
# so that Apache can talk to php-fpm and support PHP.
$ cat /etc/httpd/conf.d/php.conf
<FilesMatch "\.php$">
    # Note: The only part that varies is /path/to/app.sock
    SetHandler  "proxy:fcgi://localhost:9000"
</FilesMatch>

DirectoryIndex index.php

# Restart httpd and php-fpm
$ sudo systemctl restart httpd php73-php-fpm

And browsing to my server shows me this all worked. Amazing. Uh, I mean, I never had a doubt.

this tutorial
one of my clients