How To Install PHP on openSUSE
In this tutorial, we will show you how to install PHP on openSUSE. PHP 8.3 is the latest version of PHP, a popular server-side scripting language used in web development. This version brings several new features and improvements, making it essential for developers to stay up-to-date with the latest PHP releases. openSUSE is a robust and versatile Linux distribution that offers a stable and secure environment for developers and system administrators.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of the PHP 8.3 scripting language on openSUSE.
Prerequisites
- A server running one of the following operating systems: openSUSE.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- You will need access to the terminal to execute commands. openSUSE provides the Terminal application for this purpose. It can be found in your Applications menu.
- You’ll need an active internet connection to download PHP and its dependencies.
- You have access to a user account with sudo or root privileges.
Install PHP on openSUSE
Step 1. Firstly, we need to ensure that our openSUSE system is up-to-date. Open the terminal by pressing Ctrl + Alt + T
or by searching for ‘terminal’ in the application menu. Once the terminal is open, execute the following command to update the system:
sudo zypper refresh sudo zypper update
Step 2. Installing PHP 8.3 on openSUSE.
To install PHP 8.3, you need to add the PHP repository to openSUSE. The repository contains the latest PHP packages and updates. You can find the appropriate repository for PHP 8.3 on the openSUSE website. Add the PHP repository using the following command:
sudo zypper ar -f https://download.opensuse.org/repositories/devel:/languages:/php/openSUSE_Leap_15.4/ php
Replace openSUSE_Leap_15.4
with your openSUSE version if necessary.
Now install PHP 8.3 using the zypper package manager:
sudo zypper in php8.3
Check the installed PHP version using the following command:
php -v
The output should display the PHP 8.3 version information.
Step 3. Configuring PHP 8.3 for Web Servers.
- Configuring PHP for Apache
If you are using the Apache web server, you need to enable and configure the PHP module for Apache. Follow these steps:
sudo a2enmod php8.3
Restart Apache to apply the changes:
sudo systemctl restart apache2
- Configuring PHP for Nginx
If you are using the Nginx web server, you need to enable and configure PHP-FPM for Nginx. Follow these steps:
sudo zypper in php8.3-fpm
Enable and start PHP-FPM:
sudo systemctl enable php-fpm sudo systemctl start php-fpm
Configure Nginx to use PHP-FPM by editing the Nginx configuration file (usually located at /etc/nginx/nginx.conf
or /etc/nginx/sites-available/default
) and adding the following lines inside the location
block:
location ~ \.php$ { include fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; }
Restart Nginx to apply the changes:
sudo systemctl restart nginx
Congratulations! You have successfully installed PHP 8.3. Thanks for using this tutorial for installing the PHP scripting language on your openSUSE system. For additional or useful information, we recommend you check the official PHP website.