Install PHP on OpenSUSE 15
How to install PHP and common extensions on OpenSUSE Leap 15.1 / 15.2 / 15.3.
Step 1 — Update the System
sudo zypper refresh
sudo zypper update -y
Step 2 — Install Nginx (Optional)
sudo zypper install -y nginx
sudo systemctl enable --now nginx
Step 3 — Install PHP and Extensions
sudo zypper install -y php8 php8-fpm php8-mysql php8-curl \
php8-mbstring php8-xml php8-gd php8-zip php8-opcache php8-json
Step 4 — Start PHP-FPM
sudo systemctl enable --now php-fpm
sudo systemctl status php-fpm
Step 5 — Configure Nginx for PHP-FPM
# /etc/nginx/vhosts.d/example.conf
server {
listen 80;
server_name example.com;
root /srv/www/htdocs;
index index.php index.html;
location ~ \.php$ {
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
Verify
php -v
php -m
sudo systemctl status php-fpm nginx