July 15, 2019
  • 2:01 pm 7 Ways to Learn Linux In a Structured Manner
  • 2:00 pm How to Mount DVDs and CD-Roms Using Ubuntu
  • 1:59 pm 5 Ways to Open a Terminal Console Window Using Ubuntu
  • 1:58 pm Operating Systems: Unix vs. Windows
  • 1:57 pm Popular Flight Simulators for Linux
Pearson Education (InformIT)

NGINX is a very effective, versatile, and lightweight web server that can quickly be installed on the Linux platform. If your Linux circulation of option is Ubuntu, that procedure is even much easier. Here we’ll stroll you through the procedure of setting up the steady version of NGINX (1.14.0) on the current LTS (Long Term Assistance) release of Ubuntu Server (18.04 ).

Why Install NGINX?
You might be asking yourself, “Why install NGINX when Apache has been the default web server for many years?” The answer is a bit more complicated than you might expect. To streamline that response, consider Apache is a web server that does an amazing task of handling a large number of demands per second. However, Apache performance does start to struggle when demands increase. This means, when Apache server sees increase, page load times can suffer. On the other hand, NGINX is optimised to provide consistent and foreseeable performance. So even when page sees increase, NGINX won’t fail. On the flip side, Apache is also much more flexible than NGINX. With a lot of modules and support for other services and servers, Apache can (at the minute) do more than NGINX. So if efficiency is what you’re searching for NGINX is your server. If versatility is on top of your list, Apache must be thought about first.

Stopping and Disabling Apache
A screenshot of the commands to stop the Apache server.
The very first thing to be done is stopping and disabling Apache. If Apache is working on the server, NGINX can not be installed. Apache can stay set up the same server as NGINX, however unless Apache is stopped, NGINX will refuse to install. To discover if Apache is running, release the command:

sudo systemctl status apache2

If Apache is listed as running, you need to stop and disable it, so NGINX can be installed. To stop the Apache web server, problem the command:

sudo systemctl stop apache2
Disable the Apache server (so it doesn’t reboot in case of a server reboot) with the command:

sudo systemctl disable apache2
Installing NGINX
A screenshot of commands while setting up the NGINX web server.
With Apache taken care of, the setup of NGINX can be achieved with a single command:

sudo apt-get install nginx

When set up, begin and make it possible for NGINX with the following commands:

sudo systemctl start nginx
sudo systemctl allow nginx
The NGINX web server is now installed and running.

Viewing the NGINX Invite Page
Now that NGINX is set up, you can point your web browser to the IP address of the hosting server to see the NGINX Welcome Page. If you’re unsure of your server’s IP address, concern the command:

ip a
The output of the above command will display your server address.

Chances are, you’ll run into a problem when attempting to view the default NGINX index.html page. The issue is that, if Apache was set up first, NGINX will serve up the Apache index.html page by default. In order to see the NGINX Invite Page (index.nginx-debian. html), the Apache Invite Page should be relabelled. Back at the terminal window, problem the command:

sudo mv/ var/www/html/ index.html/ var/www/html/ index.html.old.
Go back to your web internet browser and reload that page. The Apache Invite Page ought to now be changed by the NGINX Welcome Page.

HOW TO CONFIGURE A WEBSITE.
With NGINX set up and running, it is now time to setup your very first web page. How NGINX websites are set up is done quite like Apache. Let’s stroll through the essentials of establishing a barebones site. The first thing you need to know are the necessary directories that house the files used in producing a website. These directories are:.

/ var/www/html– this is the NGINX document root, where all of your website directories and pages will be housed.
/ etc/nginx/sites-available– this is the directory that houses all of the setup apply for each of your sites.
/ etc/nginx/sites-enabled– this is the directory that advises NGINX which sites are really allowed for the server.
The difference in between sites-available and sites-enabled is twofold:.

sites-available are real files for every site you have actually developed for the server.
sites-enabled are links to the files in sites-available. Unless there is a link in sites-enabled, NGINX will not be aware of a site in sites-available.
Out of package, there will be a single file in/ etc/nginx/sites-available. That file is default. What we’re going to do is create a brand-new (bare minimum) website. The very first thing that needs to be done is to produce a directory (within the NGINX document root) to house our site. We’ll call that website test. From the terminal window, concern the command:.

sudo mkdir/ var/www/html/ test.
Develop an index.html file with the command:.

sudo nano/ var/www/html/ test/index. html.
Inside that document, include the following:.

<H1>HELLO LIFEWIRE!</H2>
Conserve and close the file with the command Ctrl-x. Offer the directory the necessary permissions with the commands:.

sudo chown www-data: www-data -R/ var/www/html/ test.
sudo chmod -R 755/ var/www/html/ test.
Now develop a setup declare our new website in/ etc/nginx/sites-available with the command:.

sudo nano/ etc/nginx/sites-available/ test.
Inside that file, include the following content:.

server

try_files $uri $uri

Save and close that file.

Check the NGINX configuration with the command:.

sudo nginx -t.
The test will show as effective. In order to make sure NGINX can display the recently crafted test site, restart the web server with the command:.

sudo systemctl reboot nginx.
You can now point your internet browser to http://SERVER_IP/test (Where SERVER_IP is the IP address of your server) to see the recently developed index.html file displayed.

finelinux

RELATED ARTICLES
LEAVE A COMMENT