How To Install Nginx on SUSE Linux Enterprise server 12

How do I install and setup Nginx server on SuSe Enterprise Linux server (SLES) version 12 SP 3?

Nginx is free and open source software. It is a very popular web server. You can replace Apache web server and use Nginx to host static, a dynamic site and a reverse proxy server for Apache. This page shows you how to install Nginx on your SUSE Linux Enterprise Server version 12.0 SP2 or SP3.

Step 1 – Configure Nginx repo

Type the following zypper command to add the zypper repository for SLES:
$ sudo zypper addrepo -G -t yum -c '' nginx

Next, you must verify digital signatures to maintain the integrity and origin of the downloaded package. Grab nginx signing key using the wget command:
$ wget
Sample outputs:

--2018-02-03 23:48:48--
Resolving (,, 2001:1af8:4060:a004:21::e3, ...
Connecting to (||:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1561 (1.5K) [text/plain]
Saving to: nginx_signing.key’
100%[==================================================>] 1,561       --.-K/s   in 0s      
2018-02-03 23:48:49 (117 MB/s) - ‘nginx_signing.key’ saved [1561/1561]

Import key to the rpm using the rpm command:
$ sudo rpm --import nginx_signing.key

Step 2 – How to install Nginx on SUSE Linux

Type the following zypper command:
$ sudo zypper install nginx

Step 3 – Setup the Firewall/Open port 80

First create Nginx service specific configuration file to open port 80 using a text editor such as vi command $ sudo vi /etc/sysconfig/SuSEfirewall2.d/services/nginx
Append the following configuration:

## Name: Nginx web server
## Description: Open ports for Nginx Server
# space separated list of allowed TCP ports

Since I haven not configured SSL certificate for my server yet, I will only need to allow traffic on TCP port number 80. Save and exit the vi/vim text editor. Now, simply run the following command to open port 80:
$ sudo yast firewall
You must use the TAB and arrow keys to navigate YaST. In YaST, navigate to Allowed Services, and then press the Enter key:

Use the TAB to navigate to Service to Allow and press Down arrow key to select Nginx web server, and then press the Enter key. You must press Alt-A to add Nginx server to firewall:

Press Alt-N and Alt-F to save and finish the firewall settings on SLES. Once returned to the shell prompt, list list all iptables rules on SLES:
$ sudo iptables -S
Sample outputs:

-A input_ext -p tcp -m limit --limit 3/min -m tcp --dport 80 --tcp-flags FIN,SYN,RST,ACK SYN -j LOG --log-prefix "SFW2-INext-ACC-TCP " --log-tcp-options --log-ip-options
-A input_ext -p tcp -m tcp --dport 80 -j ACCEPT

Use combination of sudo command and grep command to just find out if port 80 was opened or not:
sudo sh -c 'iptables -L -n -v | grep :80'

Step 4 – Turn on Nginx server

Type the following systemctl command to enable Nginx at boot time:
$ sudo systemctl enable nginx
Start your Nginx webserver:
$ sudo systemctl start nginx
Verify it:
$ systemctl status nginx

Is port 80 open?

Run the following netstat command or ss command:
$ sudo netstat -tulpn | grep :80
$ sudo ss -tulpn | grep :80

How to manage the Nginx Web server/service process

Stop Nginx web server:
$ sudo systemctl stop nginx
Start the web server:
$ sudo systemctl start nginx
Restart the service again:
$ sudo systemctl restart nginx
Reload the Ngnix after making configuration changes:
$ sudo systemctl reload nginx

Step 5 – Test Nginx server

Find out your SLES ip address using the ip command:
$ ip a s
$ ip a s eth0

Sample outputs:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 52:54:00:8a:3c:88 brd ff:ff:ff:ff:ff:ff
    inet brd scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::5054:ff:fe8a:3c88/64 scope link 
       valid_lft forever preferred_lft forever

Note down your server’s IP address Fire a web browser and type:

Another option is to run the curl command:
$ curl -I
Sample outputs:

HTTP/1.1 200 OK
Server: nginx/1.12.2
Date: Sat, 03 Feb 2018 19:18:53 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Tue, 17 Oct 2017 13:30:50 GMT
Connection: keep-alive
ETag: "59e6060a-264"
Accept-Ranges: bytes

Step 6: Finding info about Nginx config files on SLES

Now you have Nginx up and running. It is time to customize it.

Actual path to store your website content

  • /usr/share/nginx/html : You need to store all of your HTML/CSS/js/images files here.

You can upload your files using the scp command or cp command:
$ sudo cp /home/vivek/mysite-files/*.html /usr/share/nginx/html
$ scp ~/projects/*.html vivek@

Server configuration files for SLES

  • /etc/nginx/ : The default nginx config directory
  • /etc/nginx/nginx.conf : The main nginx configuration file
  • /etc/nginx/conf.d/default.conf : The default nginx config file for virtual host

Again use a text editor to edit files:
$ sudo vi /etc/nginx/nginx.conf

Nginx server logs on SLES

  • /var/log/nginx/access.log : All users visitors stored here.
  • /var/log/nginx/error.log : All server errors stored here.

Use tail command or grep command or cat command to view log files:
$ sudo tail -f /var/log/nginx/access.log
$ sudo grep 'foo' /var/log/nginx/error.log

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 0 comments... add one

CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
0 comments… add one

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Problem posting comment? Email me @