How to install and use Nginx on OpenSUSE Linux server nixCraft

How do I install and configure the latest version of Nginx web server on OpenSUSE Linux server using the CLI and host a static site?

Introduction – Nginx [engine x] is free and open source high-performance web server. It also acts as a reverse proxy server, as well as. This page shows how to install Nginx server on OpenSUSE Linux and configure a static web site.

How to install Nginx on OpenSUSE Linux

The procedure to install Nginx weber server on an RHEL 7 or CentOS Linux 7 is as follows:

  1. Login to your cloud server or bare metal server using ssh command:
    ssh user@cloud-server-ip
  2. Search for nginx package name using zypper or cnf:
    cnf nginx
  3. Install nginx package using the zypper command on OpenSUSE:
    sudo zypper update
    sudo zypper install nginx

Let us see all steps, commands and configuration in details for OpenSUSE Linux.

Search for nginx package

Find if nginx web server available on OpenSUSE by running the following cnf command and zypper command:
$ sudo zypper install nginx

Command to Install and use Nginx on OpenSUSE Linux server
Installing nginx using zypper command

How to start, stop, restart the Nginx server on OpenSUSE

Use the systemctl command:
$ sudo systemctl start nginx ## <-- start the service ##
$ sudo systemctl restart nginx ## <-- restart the service ##
$ sudo systemctl stop nginx ## <-- stop the service ##
$ sudo systemctl status nginx ## <-- Get the status of the service ##

How to enable the Nginx service at boot time on OpenSUSE

Again run the following systemctl command:
$ sudo systemctl enable nginx.service
How to start, stop, restart the Nginx on OpenSUSE Linux server
Verify that nginx is running using the ss command and TCP port 80 is open:
$ sudo ss -tulpn | grep nginx

tcp LISTEN 0 128* users:(("nginx",pid=20511,fd=6),("nginx",pid=20510,fd=6))

Configuring nginx on OpenSUSE server

Let us create a sample index.html file in /srv/www/htdocs using a text editor such as vim command:
$ sudo vi /srv/www/htdocs/index.html
Append the following html:

<html> <head> <title>OpenSUSE Linux - Nginx Server by NixCraft</title> </head> <body> <h1>Welcome</h1> <p>This is a test server for static files.</p> <hr> <small>Powered by nginx and OpenSUSE Linux server</small> </body> </html>

Save and close the file in vim text editor. Use the ip command and grep command to find out your server IP address
$ ip a s
$ ip a s eth0
$ ip a s eth0 | grep -w inet

inet brd scope global eth0

Fire a web browser and type url:

Testing Nginx on OpenSUSE Linux

Configure Nginx server

Important files and directory to configure Nginx on OpenSUSE Linux:

  • Config dir – /etc/nginx/
  • Master/Global config file – /etc/nginx/nginx.conf
  • Default TCP ports opened by Nginx – 80 (HTTP), 443 (HTTPS)
  • Document root directory – /srv/www/htdocs/
  • Virtual host domain config dir – /etc/nginx/vhosts.d/

To edit files use a text editor such as vi:
$ sudo vi /etc/nginx/nginx.conf
You can upload or copy your html/css/js and images to /srv/www/htdocs/:
$ cd /srv/www/htdocs/
$ sudo cp /backups/your-domain/*.html .
$ sudo cp /backups/your-domain/*.css .
$ sudo cp /backups/your-domain/*.png .

OR Copy from local desktop to the remote server using the rsync command or sftp command:
$ rsync -avP ~/projects/static/your-domain/* root@


In the next part of the series, you will learn how to install the latest version of PHP 7.x.x on OpenSUSE Linux server and secure communication with TLS/SSL certificates. For more info on nginx config see this page here.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Facebook Comments
Spread the love

Posted by News Monkey