Super Fast Nginx configuration for a landing page

Installing Nginx and setting up a page – below

So basically just install Nginx:

sudo apt update
sudo apt install nginx

Configuration is located at /etc/nginx/conf.d/default.conf. Say, you need just an index, a privacy policy page and a few images/styles.

server{
    server_name yourdomain.com;
    location / {
       root /usr/share/nginx/html;
       index index.html;
    }
    location /privacy {
       alias /usr/share/nginx/html;
       index privacy.html;
    }
    location /static {
       root /usr/share/nginx/html/static;
    }
}

In repository /usr/share/nginx/html you will have to place index.html and privacy.html.

In /usr/share/nginx/html/static your images and other static files. In the html pages you will link them like /styles/file.css or ./styles/file.css. Like this:

<link rel="stylesheet" href="./styles/file.css">

Use Git to load your files onto the server and here you go. To restart server do:

service nginx restart

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.