Linux

How to install and use Nginx on OpenSUSE Linux server

[ad_1]

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 [email protected]
  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

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:

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

Fire a web browser and type url:
http://server-ip/
http://192.168.2.133/

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/* [email protected]:/srv/www/htdocs/

Conclusion

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.

[ad_2]

Facebook Comments

Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button