Configuring Nginx On Your Web Server

Nginx (pronounced as "engine x") is a very popular web server used by some of the most highly visited sites out there. Nginx is notable due to its stability and low resource footprint. So let's set one up!

There are 2 ways to install nginx.
1. Directly from source
2. Pre-build package.

Using the same CentOS 6 server, easiest way to install nginx is using package from repository. You always can download latest version of Nginx from and compile it from the source. Installing from repository pretty simple really, just put the following into command line.

# yum install nginx

Configuration Nginx configuration file is called nginx.conf and you can find it in /etc/nginx. The most basic configuration will look like the block below

events { } http { server { } }

This configuration will tell Nginx to function as a http server, but before anything happens you need to start nginx:

# service nginx start

Since we're here, why don't we just keep Apache as our web server and work with clients directly as before. The problem with Apache is that it will consume a large amount of server resources (RAM especially) when it has to deal with increasing numbers of clients. Not only that, but a lot of this memory load is dependent on the clients' Internet connections. That's because Apache will keep data in its available memory pool until all the data is sent to the client.
So what does Nginx bring to the table? To help you understand, here's example where Nginx is used as proxy server for LAMP stack.

user nobody nogroup; 
worker_processes 1;
events {
    worker_connections 512;
server {
    listen *:80;
    root /var/www/iLoveLinuxSuit;
    index index.php index.htm index.html;
    location / {
        try_files $uri $uri/ /index.php;
    location ~ \.php$ {

In this configuration, the proxy server will receive every incoming request to port 80 and forward them to Apache server port 8080
(we actually need to manually change its listen port to 8080 at /etc/httpd/httpd.conf and restart Apache).
Then every client request will be processed by Apache and passed to Nginx; server resources immediately became free for another client, while Nginx can send back request results to the client.

Let’s reload nginx and we are ready:

# service nginx restart

Overall, it's not too difficult. So how can ServerSuit help? Oh hey, check out our software library:
Noticed anything? As you may have expected, we actually have an Nginx, Apache and php stack preconfigured and ready to go to any and all servers you have connected through our server dashboard. Of course, you also have the option to push Nginx to your servers as a standalone and set it up to your liking. That's all for Nginx for now. Follow us on Twitter and like our Facebook page to stay updated with news and more tech guides!

March 24 2016

Add or review comments

Please leave your comment

Existing comments

Comments 1

Hi, here on the forum guys advised a cool Dating site, be sure to register - you will not REGRET it [url=][/url]