banner



How To Install And Configure Nginx On Ubuntu 18.04

1. Overview

Nginx (pronounced equally "Engine-X") is an open up source web server that is often used as opposite proxy or HTTP enshroud. It is available for Linux for free.

In this tutorial we'll install Nginx and set upwardly a basic site.

What you'll acquire

  • How to gear up Nginx
  • Some basic Nginx configuration

What you'll need

  • A figurer running Ubuntu Server 16.04 LTS
  • Some basic knowledge of command line utilise

Originally authored by Marcin Mikołajczak


2. Installing Nginx

To install Nginx, use following control:

                sudo apt update sudo apt install nginx                              

After installing it, you lot already take everything you lot need.

Yous can signal your browser to your server IP address. You should see this folio:

If you lot come across this folio, you have successfully installed Nginx on your web server.


3. Creating our own website

Default page is placed in /var/world wide web/html/ location. Yous can place your static pages here, or use virtual host and place it other location.

Virtual host is a method of hosting multiple domain names on the same server.

Allow's create simple HTML page in /var/www/tutorial/ (information technology tin can be anything you want). Create index.html file in this location.

                cd /var/world wide web sudo mkdir tutorial cd tutorial sudo "${EDITOR:-vi}" index.html                              

Paste the following to the alphabetize.html file:

                <!doctype html> <html> <head>     <meta charset="utf-8">     <title>How-do-you-do, Nginx!</title> </head> <trunk>     <h1>Hello, Nginx!</h1>     <p>We have just configured our Nginx web server on Ubuntu Server!</p> </torso> </html>                              

Salve this file. In next step we are going to prepare virtual host to brand Nginx apply pages from this location.


4. Setting upward virtual host

To set upwardly virtual host, nosotros need to create file in /etc/nginx/sites-enabled/ directory.

For this tutorial, nosotros will make our site available on 81 port, not the standard 80 port. You lot can alter it if y'all would similar to.

                cd /etc/nginx/sites-enabled sudo "${EDITOR:-vi}" tutorial                              
                server {        listen 81;        listen [::]:81;         server_name example.ubuntu.com;         root /var/www/tutorial;        index index.html;         location / {                try_files $uri $uri/ =404;        } }                              

root is a directory where nosotros have placed our .html file. index is used to specify file available when visiting root directory of site. server_name tin be anything you want, because you aren't pointing it to any real domain by now.


five. Activating virtual host and testing results

To make our site working, simply restart Nginx service.

                sudo service nginx restart                              

Let's check if everything works equally information technology should. Open our newly created site in web browser. Call up that nosotros used :81 port.

Congratulations! Everything works every bit it should. We have just configured Nginx web server.


half dozen. That'south all!

I promise that this tutorial explained you lot the nuts of working with Nginx. Of form, information technology's much more powerful tool. Yous tin can observe more in official resources, available on Nginx site.

If you lot demand more guidance on using Nginx, help is always at hand:

  • Ask Ubuntu
  • Ubuntu Forums
  • IRC-based support

Further reading:

  • Nginx Begineer'southward Guide
  • The Consummate NGINX Cookbook – free e-book from O'Reilly

Source: https://ubuntu.com/tutorials/install-and-configure-nginx

Posted by: prudhommeeaddelartion.blogspot.com

0 Response to "How To Install And Configure Nginx On Ubuntu 18.04"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel