How to Install PHP 8.0 on openSUSE 15 Leap

PHP 8.0 is a significant update of the PHP language released on November 26, 2020, a giant leap forward from the existing PHP 7.4 release. The new PHP contains many new features and optimizations, including named arguments, union types, attributes, constructor property promotion, match expression, null safe operators, JIT and improvements in the type system, error handling, and consistency.

In the following tutorial, you will learn how to install PHP 8.0 on openSUSE 15 Leap.

Prerequisites

Update Operating System

Update your openSUSE operating system to make sure all existing packages are up to date:

sudo zypper refresh

Once refreshed, run the update command.

sudo zypper update

The tutorial will be using the sudo command and assuming you have sudo status.

To verify sudo status on your account:

sudo whoami

Example output showing sudo status:

[joshua@opensuse ~]$ sudo whoami
root

To set up an existing or new sudo account, visit our tutorial on adding a User to Sudoers on openSUSE.

To use the root account, use the following command with the root password to log in.

su

Import & Install PHP Extensions

The first task is to install the server:php:extensions in your openSUSE terminal. However, depending on the version of openSUSE you are currently running, this can vary. Below are two examples of the latest and previous releases of openSUSE Leap.

Import server:php:extensions for openSUSE Leap 15.3:

sudo zypper addrepo https://download.opensuse.org/repositories/home:/Padom/15.3/home:Padom.repo

Import server:php:extensions for openSUSE Leap 15.2:

sudo zypper addrepo https://download.opensuse.org/repositories/server:php:extensions/openSUSE_Leap_15.2/server:php:extensions.repo

Import server:php:extensions for openSUSE Leap 15.1:

sudo zypper addrepo https://download.opensuse.org/repositories/server:php:extensions/openSUSE_Leap_15.1/server:php:extensions.repo

Example output of importing 15.3:

How to Install PHP 8.0 on openSUSE 15 Leap

For newer releases, follow the formula. Once done, refresh the repository.

sudo zypper refresh

You will be prompted about the GPG key and to reject, trust temporarily, or always.

Example:

How to Install PHP 8.0 on openSUSE 15 Leap

Type “a”, then press the “ENTER BUTTON” to proceed with importing the GPG key.

Install PHP 8.0

Now that you have imported and installed the PHP extensions repository for your openSUSE system, install PHP 8.0 with the following command.

sudo zypper install php8

Example output:

How to Install PHP 8.0 on openSUSE 15 Leap

Type “Y”, then press the “ENTER KEY” to proceed with the installation.

Now that you have installed PHP 8.0 and the extensions check the version with the following command:

php -v

Example output below, remember this will change in time:

PHP 8.0.11 (cli) (built: Sep 23 2021 12:00:00) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.11, Copyright (c) Zend Technologies

How to Search for PHP 8.0 Packages

By default, when installing PHP 8.0, only a few of the main packages are installed. However, as most familiar with PHP would know, you can install many additional extras for various applications or requirements.

To search for additional packages in the PHP extensions repository, use the following command in your terminal.

sudo zypper search php8

Example output:

Loading repository data...
Reading installed packages...

S  | Name                     | Summary                                                   | Type
---+--------------------------+-----------------------------------------------------------+-----------
   | php8                     | Interpreter for the PHP scripting language version 8      | srcpackage
i+ | php8                     | Interpreter for the PHP scripting language version 8      | package
   | php8-APCu                | APCu - APC User Cache                                     | srcpackage
   | php8-APCu                | APCu - APC User Cache                                     | package
   | php8-bcmath              | "Binary Calculator" extension for PHP                     | package
   | php8-bcmath-debuginfo    | Debug information for package php8-bcmath                 | package
   | php8-bz2                 | bzip2 codec support for PHP                               | package
   | php8-bz2-debuginfo       | Debug information for package php8-bz2                    | package
   | php8-calendar            | PHP8 Extension Module                                     | package
   | php8-calendar-debuginfo  | Debug information for package php8-calendar               | package
i  | php8-cli                 | Interpreter for the PHP scripting language version 8      | package
   | php8-cli-debuginfo       | Debug information for package php8-cli                    | package
i  | php8-ctype               | Character class extension for PHP                         | package
   | php8-ctype-debuginfo     | Debug information for package php8-ctype                  | package
   | php8-curl                | libcurl integration for PHP                               | package
   | php8-curl-debuginfo      | Debug information for package php8-curl                   | package
   | php8-dba                 | Database abstraction layer for PHP                        | package
   | php8-dba-debuginfo       | Debug information for package php8-dba                    | package
   | php8-debuginfo           | Debug information for package php8                        | package
   | php8-debugsource         | Debug sources for package php8                            | package
   | php8-devel               | PHP8 development files for C/C++ extensions               | package
i  | php8-dom                 | Document Object Model extension for PHP                   | package
   | php8-dom-debuginfo       | Debug information for package php8-dom                    | package
   | php8-enchant             | Spell checking extension for PHP                          | package
   | php8-enchant-debuginfo   | Debug information for package php8-enchant                | package
   | php8-exif                | EXIF metadata extensions for PHP                          | package
   | php8-exif-debuginfo      | Debug information for package php8-exif                   | package
   | php8-fileinfo            | File identification extension for PHP                     | package
   | php8-fileinfo-debuginfo  | Debug information for package php8-fileinfo               | package
   | php8-ftp                 | FTP protocol support for PHP                              | package
   | php8-ftp-debuginfo       | Debug information for package php8-ftp                    | package
   | php8-gd                  | GD Graphics Library extension for PHP                     | package
   | php8-gd-debuginfo        | Debug information for package php8-gd                     | package
   | php8-gettext             | Native language support for PHP                           | package
   | php8-gettext-debuginfo   | Debug information for package php8-gettext                | package
   | php8-gmagick             | Wrapper to the GraphicsMagick library                     | srcpackage
   | php8-gmagick             | Wrapper to the GraphicsMagick library                     | package
   | php8-gmp                 | Bignum extension for PHP                                  | package
   | php8-gmp-debuginfo       | Debug information for package php8-gmp                    | package
   | php8-gnupg               | PHP wrapper around the gpgme library                      | srcpackage
   | php8-gnupg               | PHP wrapper around the gpgme library                      | package
   | php8-ice                 | PHP framework delivered as C extension                    | srcpackage
   | php8-ice                 | PHP framework delivered as C extension                    | package
i  | php8-iconv               | Character set conversion functions for PHP                | package
   | php8-iconv-debuginfo     | Debug information for package php8-iconv                  | package
   | php8-imagick             | Wrapper to the ImageMagick library                        | srcpackage
   | php8-imagick             | Wrapper to the ImageMagick library                        | package
   | php8-intl                | ICU integration for PHP                                   | package
   | php8-intl-debuginfo      | Debug information for package php8-intl                   | package
   | php8-ldap                | LDAP protocol support for PHP                             | package
   | php8-ldap-debuginfo      | Debug information for package php8-ldap                   | package
   | php8-lzf                 | LZF compression                                           | srcpackage
   | php8-lzf                 | LZF compression                                           | package
   | php8-maxminddb           | PHP extension providing access to maxminddb databases     | srcpackage
   | php8-maxminddb           | PHP extension providing access to maxminddb databases     | package
   | php8-mbstring            | Multibyte string functions for PHP                        | package
   | php8-mbstring-debuginfo  | Debug information for package php8-mbstring               | package
   | php8-memcache            | PHP Memcache client Extension                             | srcpackage
   | php8-memcache            | PHP Memcache client Extension                             | package
   | php8-memcached           | PHP MemcacheD client Extension                            | srcpackage
   | php8-memcached           | PHP MemcacheD client Extension                            | package
   | php8-mysql               | MySQL database client for PHP                             | package
   | php8-mysql-debuginfo     | Debug information for package php8-mysql                  | package
   | php8-odbc                | ODBC extension for PHP                                    | package
   | php8-odbc-debuginfo      | Debug information for package php8-odbc                   | package
   | php8-opcache             | Opcode cache extension for PHP                            | package
   | php8-opcache-debuginfo   | Debug information for package php8-opcache                | package
i  | php8-openssl             | OpenSSL integration for PHP                               | package
   | php8-openssl-debuginfo   | Debug information for package php8-openssl                | package
   | php8-pcntl               | Process Control extension for PHP                         | package
   | php8-pcntl-debuginfo     | Debug information for package php8-pcntl                  | package
i  | php8-pdo                 | PHP Data Objects extension for PHP                        | package
   | php8-pdo-debuginfo       | Debug information for package php8-pdo                    | package
   | php8-pear                | PHP Extension and Application Repository                  | package
   | php8-pear                | PHP Extension and Application Repository                  | srcpackage
   | php8-pecl                | PHP Extension Community Library                           | package
   | php8-pgsql               | PostgreSQL database client for PHP                        | package
   | php8-pgsql-debuginfo     | Debug information for package php8-pgsql                  | package
   | php8-phar                | PHP Archive extension for PHP                             | package
   | php8-phar-debuginfo      | Debug information for package php8-phar                   | package
   | php8-posix               | POSIX functions for PHP                                   | package
   | php8-posix-debuginfo     | Debug information for package php8-posix                  | package
   | php8-psr                 | PSR Extension Module                                      | srcpackage
   | php8-psr                 | PSR Extension Module                                      | package
   | php8-readline            | PHP8 readline extension                                   | package
   | php8-readline-debuginfo  | Debug information for package php8-readline               | package
   | php8-redis               | API for communicating with Redis servers                  | srcpackage
   | php8-redis               | API for communicating with Redis servers                  | package
   | php8-shmop               | Alternate, low-level shared memory implementation for PHP | package
   | php8-shmop-debuginfo     | Debug information for package php8-shmop                  | package
   | php8-smbclient           | A PHP wrapper for libsmbclient                            | srcpackage
   | php8-smbclient           | A PHP wrapper for libsmbclient                            | package
   | php8-snmp                | SNMP extension for PHP                                    | package
   | php8-snmp-debuginfo      | Debug information for package php8-snmp                   | package
   | php8-soap                | SOAP/WSDL extension module for PHP                        | package
   | php8-soap-debuginfo      | Debug information for package php8-soap                   | package
   | php8-sockets             | Berkeley sockets API for PHP                              | package
   | php8-sockets-debuginfo   | Debug information for package php8-sockets                | package
   | php8-sodium              | Cryptographic Extension Based on Libsodium                | package
   | php8-sodium-debuginfo    | Debug information for package php8-sodium                 | package
i  | php8-sqlite              | SQLite database client for PHP                            | package
   | php8-sqlite-debuginfo    | Debug information for package php8-sqlite                 | package
   | php8-sysvmsg             | SysV Message Queue support for PHP                        | package
   | php8-sysvmsg-debuginfo   | Debug information for package php8-sysvmsg                | package
   | php8-sysvsem             | SysV Semaphore support for PHP                            | package
   | php8-sysvsem-debuginfo   | Debug information for package php8-sysvsem                | package
   | php8-sysvshm             | SysV Shared Memory support for PHP                        | package
   | php8-sysvshm-debuginfo   | Debug information for package php8-sysvshm                | package
   | php8-tidy                | PHP8 binding for the Tidy HTML cleaner                    | package
   | php8-tidy-debuginfo      | Debug information for package php8-tidy                   | package
i  | php8-tokenizer           | Extension module to access Zend Engine's PHP tokenizer    | package
   | php8-tokenizer-debuginfo | Debug information for package php8-tokenizer              | package
   | php8-uploadprogress      | An php extension to track progress of a file upload       | srcpackage
   | php8-uploadprogress      | An php extension to track progress of a file upload       | package
   | php8-uuid                | PHP UUID support functions                                | srcpackage
   | php8-uuid                | PHP UUID support functions                                | package
   | php8-xdebug              | Extended PHP debugger                                     | srcpackage
   | php8-xdebug              | Extended PHP debugger                                     | package
i  | php8-xmlreader           | Streaming XML reader extension for PHP                    | package
   | php8-xmlreader-debuginfo | Debug information for package php8-xmlreader              | package
i  | php8-xmlwriter           | Streaming-based XML writer extension for PHP              | package
   | php8-xmlwriter-debuginfo | Debug information for package php8-xmlwriter              | package
   | php8-xsl                 | PHP8 Extension Module                                     | package
   | php8-xsl-debuginfo       | Debug information for package php8-xsl                    | package
   | php8-zip                 | ZIP archive support for PHP                               | package
   | php8-zip-debuginfo       | Debug information for package php8-zip                    | package
   | php8-zlib                | Zlib compression support for PHP                          | package
   | php8-zlib-debuginfo      | Debug information for package php8-zlib                   | package

To install the PHP 8.0 Redis extension from the list, you would execute the following command:

sudo zypper install php8-redis

Example output:

How to Install PHP 8.0 on openSUSE 15 Leap

Type “Y”, then press the “ENTER KEY” to proceed with the installation.

The same principle can be used for PHP 7.4. Just replace the 8 with 7.

sudo zypper search php7

By default, all packages installed with php7 will be PHP 7.4.

Nginx – How to Install PHP-FPM

By default, the Nginx FPM module does not come natively in the PHP extensions by openSUSE. To install this, you will need to install one of the community repositories. One of the recommended ones is Padom’s repository which is listed as an alternative on openSUSE’s packages search.

First, you will need to add the respective repository.

openSUSE Leap 15.3

sudo zypper addrepo https://download.opensuse.org/repositories/home:/Padom/15.3/home:Padom.repo

openSUSE Leap 15.2:

sudo zypper addrepo https://download.opensuse.org/repositories/home:Padom/openSUSE_Leap_15.2/home:Padom.repo

openSUSE Leap 15.1:

sudo zypper addrepo https://download.opensuse.org/repositories/home:Padom/openSUSE_Leap_15.1/home:Padom.repo

Refresh the repository, and accept the GPG import of the repository you selected.

sudo zypper refresh

Next, install the Nginx PHP-FPM 8 extension.

sudo zypper install php8-fpm

You will be prompted about the GPG key and to reject, trust temporarily, or always.

Example output:

How to Install PHP 8.0 on openSUSE 15 Leap

Type “a”, then press the “ENTER BUTTON” to proceed with importing the GPG key.

Example output:

How to Install PHP 8.0 on openSUSE 15 Leap

Type “Y”, then press the “ENTER KEY” to proceed with the installation.

Once installed, copy the default configuration files to their respective names.

Failure to do this will result in PHP-FPM giving an error status.

sudo cp /etc/php8/fpm/php-fpm.conf.default /etc/php8/fpm/php-fpm.conf
sudo cp /etc/php8/fpm/php-fpm.d/www.conf.default /etc/php8/fpm/php-fpm.d/www.conf

Now, by default, PHP-FPM is disabled. To enable PHP FPM to use the following command.

sudo systemctl enable php-fpm --now

Next, confirm PHP-FPM is working correctly.

sudo systemctl status php-fpm

Example output:

How to Install PHP 8.0 on openSUSE 15 Leap

As above, PHP-FPM is working correctly and will be updated using the community repository. Alternatively, you can install all your PHP 8 extensions from this repository. It is highly regarded and, as with FPM added, has more extensions than the official repository.

Comments and Conclusion

In the tutorial, you have learned how to import the PHP extensions repository for your version of openSUSE and install additional packages and search for them. Overall, PHP 8.0 is now starting to become pretty standard everywhere.

With the development of the upcoming PHP 8.1, more developers are now making their web applications PHP 8 friendly, including the giant CMS WordPress with more theme and plugin devs racing to get PHP 8.0 supported given the advantages 8 has in security and speed compared the 7 series.



Follow LinuxCapable.com!

Like to get automatic updates? Follow us on one of our social media accounts!