Nginx Installation Steps and Methods

Tadashi Shigeoka ·  Sun, September 11, 2011

I installed Nginx, so I’ll introduce the steps and methods.

Nginx
nginx (pronounced "engine-x") is a lightweight, high-performance web server/reverse proxy, and also an email (IMAP/POP3) proxy.

・Source: nginx - Wikipedia

Installation Steps

■ Install GCC, PCRE, zlib, OpenSSL

First, install the necessary components for compiling Nginx.

# yum -y install gcc
# yum -y install pcre pcre-devel
# yum -y install zlib zlib-devel
# yum -y install openssl openssl-devel

■ Install Nginx

The latest version available through yum seems to be nginx 0.8.54.

By the way, the stable version is nginx-1.0.4, released on 2011-06-01, which is the latest.

# yum info nginx
Available Packages
Name       : nginx
Arch       : x86_64
Version    : 0.8.54
Release    : 1.el5
Size       : 389 k
Repo       : epel
Summary    : Robust, small and high performance HTTP and reverse proxy server
URL        : http://nginx.net/
License    : BSD
Description: Nginx [engine x] is an HTTP(S) server, HTTP(S) reverse proxy and
           : IMAP/POP3 proxy server written by Igor Sysoev.

Let’s install it right away.

# yum -y install nginx

Check if it’s properly installed.

# nginx -v
nginx version: nginx/0.8.54

Options can be checked with nginx -h.

# nginx -h
nginx version: nginx/0.8.54
Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]

Options:
  -?,-h         : this help
  -v            : show version and exit
  -V            : show version and configure options then exit
  -t            : test configuration and exit
  -q            : suppress non-error messages during configuration testing
  -s signal     : send signal to a master process: stop, quit, reopen, reload
  -p prefix     : set prefix path (default: /usr/share/nginx/)
  -c filename   : set configuration file (default: /etc/nginx/nginx.conf)
  -g directives : set global directives out of configuration file

For example, you can check what configure options were used during installation with nginx -V.

(Configure options are displayed with line breaks for readability.)

# nginx -V
nginx version: nginx/0.8.54
built by gcc 4.1.2 20080704 (Red Hat 4.1.2-50)
TLS SNI support disabled
configure arguments:
--user=nginx
--group=nginx
--prefix=/usr/share/nginx
--sbin-path=/usr/sbin/nginx
--conf-path=/etc/nginx/nginx.conf
--error-log-path=/var/log/nginx/error.log
--http-log-path=/var/log/nginx/access.log
--http-client-body-temp-path=/var/lib/nginx/tmp/client_body
--http-proxy-temp-path=/var/lib/nginx/tmp/proxy
--http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi
--http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi
--http-scgi-temp-path=/var/lib/nginx/tmp/scgi
--pid-path=/var/run/nginx.pid
--lock-path=/var/lock/subsys/nginx
--with-http_ssl_module --with-http_realip_module
--with-http_addition_module
--with-http_xslt_module
--with-http_image_filter_module
--with-http_geoip_module
--with-http_sub_module
--with-http_dav_module
--with-http_flv_module
--with-http_gzip_static_module
--with-http_random_index_module
--with-http_secure_link_module
--with-http_degradation_module
--with-http_stub_status_module
--with-http_perl_module --with-mail
--with-file-aio --with-mail_ssl_module
--with-ipv6
--with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic'
--with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic'

■ Register with Service and Set Auto-start

# chmod +x /etc/rc.d/init.d/nginx
# chkconfig --add nginx
# chkconfig nginx on
# chkconfig --list nginx
nginx            0:off  1:off  2:on  3:on  4:on  5:on  6:off

The installation steps are complete.

That’s all from the Gemba.