How To install Nginx 1.17.4 on Arch Linux

This guide is intended to install nginx on a server running Arch Linux. You can download this system to your ISO disk of a virtual machine.

In order to install nginx you will need to enter the following command:

# pacman -S nginx-mainline

To start Nginx after each boot you need to enter:

# systemctl enable --now nginx

Then we check the functionality of Nginx. Visit http:// YOUR-SERVER-WEB-ADDRESS-OR-IP and you will see its welcome page. (Run ip addr if you need to know, find the IP address.)

Nginx configuration files are located in/etc/nginx, and its main file is nginx.conf. The string server.location.root/usr/share/nginx/html; sets where it will search for web files

Virtual host configuration

On a web server, you can host several domain names at once and serve them with different content and in different directions. You need to create a folder in order to store the settings of your virtual host

# mkdir /etc/nginx/sites-enabled

Next, you need to create a configuration file for each virtual host; Example: /etc/nginx/sites-enabled/EXAMPLE.COM and fill it with the following configuration:

server {
    listen 80;
    server_name EXAMPLE.COM;

    location / {
        root /usr/share/nginx/YOUR-DOMAIN-NAME.com;
        index  index.html index.htm;
    }
}

At the end of the http block /etc/nginx/nginx.conf, add the following line:

include sites-enabled/*;

Then you need to restart Nginx:

# systemctl restart nginx

Requests received by Nginx, EXAMPLE.COM will be processed by /usr/share/nginx/EXAMPLE.COM

Was this article helpful?

Related Articles

Leave A Comment?