openSUSE

How To Install LEMP Stack on openSUSE

In this tutorial, we will show you how to install LEMP Stack on openSUSE. The LEMP stack, an acronym for Linux, Nginx, MySQL/MariaDB, and PHP, is a powerful combination of open-source software used for hosting dynamic websites and web applications.

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 LEMP 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 Nginx, MariaDB, PHP, and its dependencies.
  • You’ll need administrative (root) access or a user account with sudo privileges.

Install LEMP Stack on openSUSE

Step 1. Before installing LEMP, it’s a good practice to update the package lists for upgrades and new installations. You can do this with the following command:

sudo zypper refresh
sudo zypper update

Step 2. Installing Nginx Web Server.

Nginx (pronounced “engine-x”) is a powerful web server known for its high performance and low memory usage. Here’s how to install it on openSUSE.

Now install Nginx using the zypper package manager:

sudo zypper install nginx

After installing Nginx, you need to start the Nginx service. You can do this with the following command:

sudo systemctl start nginx

To ensure that Nginx starts automatically at boot, you need to enable it:

sudo systemctl enable nginx

To verify that Nginx was installed correctly and is running, you can check the status of the service:

sudo systemctl status nginx

You can also verify that Nginx is serving pages by accessing your server’s domain or IP address in a web browser. If Nginx is correctly installed and running, you should see the default Nginx landing page.

Step 3. Installing MariaDB.

MariaDB is a community-developed fork of the MySQL relational database management system. It’s designed to maintain high compatibility with MySQL, ensuring a drop-in replacement capability with library binary equivalency and exact matching with MySQL APIs and commands. To install MariaDB using the zypper package manager:

sudo zypper install mariadb-server

After installing MariaDB, you need to start the MariaDB service:

sudo systemctl start mariadb

To ensure that MariaDB starts automatically at boot, you need to enable it:

sudo systemctl enable mariadb

MariaDB includes a script that helps secure your database server. Run the script by entering the following command:

sudo mysql_secure_installation

This script will guide you through the process of securing your MariaDB installation. It will prompt you to set a root password, remove anonymous users, disallow remote root login, and remove the test database.

To verify that MariaDB was installed correctly and is running, you can check the status of the service:

sudo systemctl status mariadb

You can also test your setup by logging into MariaDB using the following command:

mysql -u root -p

Enter the root password you set during the secure installation process. If MariaDB is correctly installed and running, you should be logged into the MariaDB shell.

Step 4. Installing PHP.

PHP is a popular server-side scripting language designed for web development. It’s used in the LEMP stack to process code to display dynamic content to users.

To install PHP 8.3, you need to add the PHP repository to openSUSE. You can do this with the following command:

sudo zypper addrepo --refresh https://download.opensuse.org/repositories/devel:/languages:/php/openSUSE_Leap_15.6/ php

Next, install PHP 8.3 using the zypper package manager:

sudo zypper refresh
sudo zypper install php8.3-fpm

To configure Nginx to use PHP, you need to edit the Nginx configuration file. Open the file with a text editor such as nano:

sudo nano /etc/nginx/nginx.conf

In the server block, add the following lines:

location ~ \.php$ {
    try_files $uri =404;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    include fastcgi_params;
}

This configuration tells Nginx to pass PHP requests to the PHP FastCGI processor on localhost at port 9000.

After configuring Nginx to use PHP, you need to restart both the Nginx and PHP-FPM services for the changes to take effect:

sudo systemctl restart nginx
sudo systemctl restart php8.3-fpm

To verify that PHP was installed correctly, you can create a PHP info file in the web root directory:

echo "<?php phpinfo(); ?>" | sudo tee /srv/www/htdocs/info.php

Then, access this file in a web browser by navigating to http://server_domain_or_IP/info.php. If PHP is correctly installed and running, you should see a page displaying information about your PHP installation.

Congratulations! You have successfully installed LEMP. Thanks for using this tutorial for installing the LEMP Stack on your openSUSE system. For additional or useful information, we recommend you check the official openSUSE website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button