PHP 7.4 is available for production use with lots of new features, improvements and deprecated ones as well. In this guide we show Linux users how they can install and use PHP 7.4 on openSUSE 15 Linux system. PHP is a server-side HTML embedded scripting language designed primarily for web development but also can also be used as a general-purpose programming language.

We assume you already have a newly installed and running openSUSE machine which can be in the Cloud, on premise virtualization platform, on VirtualBox or Vagrant provisioned machine.

Update System

Before any installations we advise users to ensure their Linux system is up-to-date. On openSUSE 15 use below commands to update the system.

sudo zypper refresh
sudo zypper update -y

Add PHP repository to your openSUSE 15 system.

openSUSE 15.2:

sudo zypper addrepo php

openSUSE 15.1:

sudo zypper addrepo php

Accept signing key importation:

New repository or package signing key received:

  Repository:       php
  Key Name:         devel:languages:php OBS Project <devel:languages:[email protected]>
  Key Fingerprint:  55CF98B4 BB5BC6CC 2E24748F 82EE4011 CBCA8BB5
  Key Created:      Mon Jan 14 00:02:23 2019
  Key Expires:      Wed Mar 24 00:02:23 2021
  Rpm Name:         gpg-pubkey-cbca8bb5-5c3bd18f

Do you want to reject the key, trust temporarily, or trust always? [r/t/a/?] (r): a
Retrieving repository 'php' metadata .....................................[done]
Building repository 'php' cache ..........................................[done]
Repository 'openSUSE-Update-Non-Oss' is up to date.
All repositories have been refreshed.

Install PHP 7.4 on openSUSE 15

Install PHP 7.4 on openSUSE 15 using the command below.

sudo zypper install php7

Agree to the installation prompt:

The following 13 NEW packages are going to be installed:
  php7 php7-ctype php7-dom php7-iconv php7-json php7-pdo php7-sqlite
  php7-tokenizer php7-xmlreader php7-xmlwriter postfix system-user-mail

The following 9 recommended packages were automatically selected:
  php7-ctype php7-dom php7-iconv php7-json php7-sqlite php7-tokenizer
  php7-xmlreader php7-xmlwriter postfix

The following 4 packages are suggested, but will not be installed:
  php7-gd php7-gettext php7-mbstring php7-mysql

13 new packages to install.
Overall download size: 3.2 MiB. Already cached: 0 B. After the operation,
additional 14.3 MiB will be used.
Continue? [y/n/v/...? shows all options] (y): y

To install php extension use the command syntax:

$ sudo zypper install php7-<extension>


sudo zypper install php7-zip php7-fpm php7-gd php7-gettext php7-mbstring php7-mysql

Confirm php version.

$ php --version
PHP 7.4.13 (cli) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

To check loaded PHP modules use the following command:

$ php -m
[PHP Modules]

[Zend Modules]

Running PHP 7.4 with Apache

Install apache2-mod_php7 package

sudo zypper in apache2-mod_php7

Load PHP apache module

sudo a2enmod php7

Then start and enable apache2 service.

sudo systemctl restart apache2
sudo systemctl enable apache2


sudo tee /srv/www/htdocs/index.php<<EOF
<div style="width: 100%; font-size: 40px; font-weight: bold; text-align:center;">
    print "PHP Hello Page";

Access http://server_ip_or_hostname/index.php

Running PHP 7.4 with Nginx

Stop and disable apache2 service:

sudo systemctl disable --now apache2

Install Nginx:

sudo zypper install nginx
sudo systemctl enable --now nginx

Install php7-fpm package.

sudo zypper install php7-fpm

Create configuration files from templates:

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

Edit the configuration:

$ sudo vim /etc/php7/fpm/php-fpm.conf
error_log = log/php-fpm.log

Set user and group.

$ sudo vim /etc/php7/fpm/php-fpm.d/www.conf
user  = nginx
group = nginx

When done start and enable service:

sudo systemctl enable --now php-fpm

Confirm status:

$ systemctl status php-fpm
● php-fpm.service - The PHP FastCGI Process Manager
   Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2020-12-01 21:46:23 UTC; 1min 51s ago
 Main PID: 5273 (php-fpm)
   Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec"
    Tasks: 3
   CGroup: /system.slice/php-fpm.service
           ├─5273 php-fpm: master process (/etc/php7/fpm/php-fpm.conf)
           ├─5274 php-fpm: pool www
           └─5275 php-fpm: pool www

Dec 01 21:46:23 opensuse15 systemd[1]: Starting The PHP FastCGI Process Manager...
Dec 01 21:46:23 opensuse15 systemd[1]: Started The PHP FastCGI Process Manager.

Create test index page.

sudo tee /srv/www/htdocs/index.php<<EOF
<div style="width: 100%; font-size: 40px; font-weight: bold; text-align:center;">
    print "PHP Hello from Nginx";

Edit Nginx configuration to pass the PHP scripts to FastCGI server listening on

$ sudo vim /etc/nginx/nginx.conf
# Line 78/79
location ~ \.php$ {
            root           /srv/www/htdocs/;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi_params;

Restart nginx and php-fpm:

sudo systemctl restart php-fpm nginx

In this article we’ve been able to install PHP 7.4 and configure both Apache and Nginx web servers to serve PHP scripts. You can also check out other guides we have on openSUSE and Web hosting.

How To Install PostgreSQL 13 on openSUSE 15

Setup WordPress 5 website with Nginx on Amazon Linux 2

How To Install PhpMyAdmin on Oracle Linux 8