Friday, October 22, 2010

Installing Nginx on Red Hat/CentOS

Nginx is an open source web server, and over the past few years it's started to become a popular alternative to the dominant Apache HTTP server.

It is possible to install Nginx using the yum package manager, but it's a much better idea to install it from source.

You cannot install it using the standard repositories, so you'll need to add the EPEL (Extra Packages for Enterprise Linux) repository first. This is easily done using the latest installation rpm which can be found at:

http://fedoraproject.org/wiki/EPEL/FAQ#howtouse

Once EPEL is added to yum's repo list, you can install Nginx by simply running the command:

yum install nginx

The only problem being, the version available via EPEL is out of date. At time of writing, using yum will install version 0.6.36, which has been listed as a stable 'legacy' version since April 2009.

The current stable version is 0.7.67, which is thirteen versions up from the version available using yum, so it's always advisable to install it from source using the latest stable release.

The latest version can be downloaded from:

http://wiki.nginx.org/NginxInstall

This page also includes the basic build instructions. These are the standard three steps for building from source:

./configure
make
make install
(or sudo make install, if you're not root)

Before running configure, it's worth checking the list of compile-time options available. They're all listed at:

http://wiki.nginx.org/NginxInstallOptions

The modules installed as standard can be found listed at:

http://wiki.nginx.org/NginxModules

If there are any listed you do not want installed, you can use one of the '–without-*' arguments listed to exclude them.

Once Nginx is installed, you'll need to add an init script, as this won't be created when installing from source.

If you're feeling adventurous, you can try writing your own, otherwise you can use the standard version listed at:

http://wiki.nginx.org/RedHatNginxInitScript


This will respond to the familiar Apache style options, e.g. start, stop, restart, configtest, etc.

0 comments:

Post a Comment