Learn How To Install Nginx 1.14 On Arch Linux

March 4, 2020

Table of Contents


https://www.itweb.services/tutorials/linux-guides/installing-2019-arch-linux-on-a-itweb.services-server”>this article.)

  • Sudo access.
    • Commands required to be ran as root are prefixed by #. The recommended way to run commands as root is to, as a regular user, prefix each of them with sudo.
  • Have a text editor installed, and be familiar with it, such as vi, vim, nano, emacs, or another similar editor
  • Install Nginx 1.14 Web Server

    If you are using a firewall, you will need to enable incoming TCP traffic to port 80.

    Install Nginx. There’s also the nginx package which is the stable branch instead of mainline, which is sort of like a long term support branch. It’s recommended to use the mainline branch, unless third party modules you need to use are incompatible with it:

    # pacman -S nginx-mainline

    Start Nginx, and make it start after every boot:

    # systemctl enable --now nginx

    Test that Nginx is running. 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’s configuration files are in /etc/nginx, and its main one is nginx.conf. The line server.location.root /usr/share/nginx/html; sets where it will look for web files. By default, the main Nginx process runs as root, but its worker processes run as user http. Nginx will be logged to /var/log/nginx/access.log.

    Virtual Hosts

    You can host multiple domain names from the same Nginx server, and serve them different content.

    Create a folder to hold your virtual host configurations:

    # mkdir /etc/nginx/sites-enabled

    Create a configuration file for each virtual host; for example, /etc/nginx/sites-enabled/YOUR-DOMAIN-NAME.com; and populate it with the following configuration:

    server {
        listen 80;
        server_name YOUR-DOMAIN-NAME.com;
        location / {
            root /usr/share/nginx/YOUR-DOMAIN-NAME.com;
            index  index.html index.htm;

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

    include sites-enabled/*;

    Restart Nginx:

    # systemctl restart nginx

    Requests Nginx receives to YOUR-DOMAIN-NAME.com will be served out of /usr/share/nginx/YOUR-DOMAIN-NAME.com. Note requests to Nginx not matching a specific server_name, (just the IP address, or another domain name resolving to your IP), will still be served out of the general server block location.root in /etc/nginx/nginx.conf, which defaults to /usr/share/nginx/html/.

    Need help?

    Do you need help setting up this on your own service?
    Please contact us and we’ll provide you the best possible quote!