ada recommended color contrast radios be damned

Install PHP 8.0 FPM for WordPress

Ubuntu server software comes with many default, pre-installed packages. When this post was first created, Ubuntu 20.04 default repositories only included PHP 7.4 and I wanted PHP 8.0. So it took a little extra doing to make that happen.

The video takes you through the process outlined below.

Install PHP 8.0 FPM

SSH into the web server with an SSH key pair:

ssh -i ~/.ssh/supernifty supernifty@143.198.116.106 RETURN

Update the available package information for the software already installed on your server:

sudo apt update RETURN

Install software-properties-common – a software package that makes it easier to manage third-party software:

sudo apt install software-properties-common RETURN

Add a PHP software repository maintained by a developer named Ondřej Surý that includes multiple PHP versions – including PHP 8.0:

sudo add-apt-repository ppa:ondrej/php RETURN

Install PHP 8.0 and a high-performance alternative to Apache’s module mod_fastcgi.

sudo apt install php8.0-fpm libapache2-mod-fcgid RETURN

Enable the fcgi module and set the variables sent to it:

sudo a2enmod proxy_fcgi setenvif RETURN

Enable the PHP FPM config and PHP FPM itself:

sudo a2enconf php8.0-fpm RETURN

sudo systemctl enable php8.0-fpm RETURN

Install the required set of PHP software packages WordPress needs to function properly:

sudo apt install php8.0-{bcmath,cli,common,curl,dev,gd,imap,imagick,intl,mbstring,mcrypt,mysql,opcache,soap,xml,zip} -y RETURN

Use the nano text editor to open the PHP configuration file (php.ini):

sudo nano /etc/php/8.0/fpm/php.ini RETURN

and update some of the default settings as indicated below:

upload_max_filesize = 32M
post_max_size = 48M
memory_limit = 256M
max_execution_time = 600
max_input_vars = 3000
max_input_time = 1000

Once you’re finished updating the php.ini file, CONTROL-O, RETURN and CONTROL-X to save it and quit out of the nano text editor.

Now restart Apache so that the changes will take effect:

sudo service apache2 restart RETURN

Once Apache restarts, you can confirm the installation by running:

php -v RETURN

which should return a response similar to:

PHP 8.0.12 (cli) (built: Oct 21 2021 14:38:26) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.12,
Copyright (c) Zend Technologies with Zend OPcache v8.0.12,
Copyright (c), by Zend Technologies

To test the PHP install in a web browser, you can create a phpinfo() file :

echo ‘<?php phpinfo();?>’ /var/www/supernifty.com/public_html/banana.php RETURN

and then open it in a web browser (eg: https://supernifty.com/banana.php) to see how everything is configured. Be sure to delete the phpinfo() file right away, it exposes way too much information about your server and is a huge security risk!

With all the steps above completed, it’s time to secure PHP-FPM 8.0 permissions so that it will work properly with WordPress.