In the realm of web server administration, the process of setting up a LEMP Stack on the openSUSE operating system is a critical task that every system administrator needs to master. This article aims to guide you through this process with a comprehensive step-by-step walkthrough.
Setting Up Your openSUSE Server
Before we install the LEMP stack, it’s good practice to update the package lists for upgrades and new installations. This can be achieved with the following command:
sudo zypper refresh sudo zypper update
Installing Nginx Web Server
Nginx (pronounced “engine-x”) is a robust web server renowned for its high performance and low memory usage. Here’s how you can install it on openSUSE.
sudo zypper install nginx
After installing Nginx, start the service using the following command:
sudo systemctl start nginx
To ensure that Nginx starts automatically at boot, enable it with this command:
sudo systemctl enable nginx
To verify that Nginx was installed correctly and is running, check the status of the service:
sudo systemctl status nginx
Access your server’s domain or IP address in a web browser to verify that Nginx is serving pages. You should see the default Nginx landing page if it is correctly installed and running.
Installing MariaDB
MariaDB is a community-developed fork of the MySQL relational database management system. To install MariaDB, use the following command:
sudo zypper install mariadb-server
Start the MariaDB service after installation:
sudo systemctl start mariadb
Enable MariaDB to ensure it starts automatically at boot:
sudo systemctl enable mariadb
Run the following script to secure your database server:
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
Test your setup by logging into MariaDB using the 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.
Installing PHP
PHP is a popular server-side scripting language designed for web development. To install PHP 8.3, add the PHP repository to openSUSE 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, edit the Nginx configuration file:
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, 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 correctly installed, create a PHP info file in the web root directory:
echo "<?php phpinfo(); ?>" | sudo tee /srv/www/htdocs/info.php
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.
Installing LEMP Stack on openSUSE is a crucial step in setting up your web server for hosting dynamic websites and web applications. This article has aimed to provide a comprehensive guide on this process.
For those who prefer not to deal with server management and would rather focus on their businesses, there are managed solutions available. Shape.host offers Cloud VPS services, taking care of server management while you focus on what matters most – your business.