Nginx is a light weight high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. Nginx is known for its high performance, stability, rich feature set, simple configuration, and low resource consumption.
This guide describes how to start and stop Nginx, and reload its configuration, explains the structure of the configuration file and describes how to set up Nginx to serve out static content and how to configure Nginx as a proxy server.
$ sudo apt-get update $ sudo apt-get install nginx
if the above commands do not work for you click here for more info It can also be found in Ubuntu Software Center. Go, search for it and install from GUI.
Starting, Stopping, and Reloading Configuration
The commands can be used to start / stop / restart the nginx server on a Ubuntu Linux:
$ sudo service nginx start $ sudo service nginx stop $ sudo service nginx restart
$ sudo /etc/init.d/nginx start $ sudo /etc/init.d/nginx stop $ sudo /etc/init.d/nginx restart
$ nginx -s signal
Where signal may be one of the following:
stop— fast shutdown
quit— graceful shutdown
reload— reloading the configuration file
reopen— reopening the log files
for more info on this topic visit the link
Nginx has one master process and several worker processes. The main purpose of the master process is to read and evaluate configuration, and maintain worker processes. Worker processes do actual processing of requests. The number of worker processes is defined in the configuration file and may be fixed for a given configuration or automatically adjusted to the number of available CPU cores (see worker_processes). The way nginx and its modules work is determined in the configuration file. By default, the configuration file is named
nginx.conf and placed in the directory
Now you need to configure the Nginx to serve the assets you request from browsers. Nginx consists of modules which are controlled by directives specified in the configuration file. Directives are divided into simple directives and block directives.
A simple directive consists of the name and parameters separated by spaces and ends with a semicolon (
A block directive has the same structure as a simple directive, but instead of the semicolon it ends with a set of additional instructions surrounded by braces (
}). If a block directive can have other directives inside braces, it is called a context (examples: events, http,server, and location).
An important web server task is serving out files (such as images or static HTML pages). You will implement an example where, depending on the request, files will be served from different local directories:
/data/www(which may contain HTML files) and
/data/images (containing images). To learn more about Serving Static Content click here
For getting the list of all running Nginx processes, the
ps utility may be used, for example, in the following way:
$ ps -ax | grep nginx
For more information on sending signals to nginx, see Controlling nginx. To be continued.. Sources: http://wiki.nginx.org/Main