Skip to content

NGINX

Other Resources

NGINX Configuration Guide

nginx logo
  • What is NGINX?

    NGINX is a high efficiency load balancer, request manipulator and static file server. The high efficiency comes from it's event-based architecture (as opposed to competing threaded or process-driven approaches).

NGINX is fairly straightforward to install and provides a lot of punch right out of the box. Let’s dive in and get started!

Contents

Quickstart

Install the NGINX package from your favorite package manager. Here’s an example with yum:

				
					yum install -y nginx
				
			

Create a directory at /etc/nginx/sites-available and /etc/nginx/sites-enabled for our site-specific configurations.

Open the configuration file created in /etc/nginx/nginx.conf. Include the following line at the end of the http {} configuration block: 

				
					include /etc/nginx/sites-enabled/*;
				
			

Start your NGINX service using the service start command. Configure nginx to auto-start using chkconfig on.

				
					service nginx start
chkconfig nginx on
				
			
Ready to get the whole story on your uptime?
 
Status List delivers uptime checks with technical diagnostics in a one dashboard. A pass/fail isn’t the whole story.
 
Join over 2,000 companies and try it for free today.

Adding a Site

Create a new file in /etc/nginx/sites-available called mydomain.com.conf. This is where we’ll place your domain-specific configuration. To make the site enabled, create a symbolic link to your configuration in the /etc/nginx/sites-enabled directory. Here’s an example:

				
					# /etc/nginx/sites-available/statuslist.app.conf
server {
    listen 80;
    server_name statuslist.app;
    root /opt/statuslist/www;
    
    location / {
        try_files $uri $uri/
    }
}

cd /etc/nginx/sites-enabled
ln -s statuslist.app.conf ../sites-available/statuslist.app.conf
				
			

NGINX Config Test

It’s important to test your config before you reload NGINX. If you have something wrong, NGINX will stop operating and your site will go down. It’s really easy to test your config. Run the nginx -t command and NGINX will print the validation results. See below for an example:

				
					nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
				
			

More Reading

Optimized with PageSpeed Ninja