Installing Nginx on CentOS Linux
From ISPWiki
Contents |
Installing Nginx on CentOS Linux
(checked 15.07.2010 on CentOS 5.5 32bit) The following document describes how to install an Nginx web-server under CentOS Linux as front-end to ISPmanager.
Ngnix is not included into the CentOS Linux distribution, so you need to use a third-party repository to install it; in our case use the centos.alt.ru. repository.
You also need to install the mod_rpaf module for Apache to correctly recognize a client's IP-address.
Step-by-step instruction
- Configure a third-party repository with Nginx and mod_rpaf (you must have root privileges):
For i386 architecture (32-bit operating system)
rpm -ihv http://centos.alt.ru/repository/centos/5/i386/centalt-release-5-3.noarch.rpm
For x86_64 architecture (64-bit operating system)
rpm -ihv http://centos.alt.ru/repository/centos/5/x86_64/centalt-release-5-3.noarch.rpm
Update the yum and ISPmanager packet cache:
yum makecache /usr/local/ispmgr/sbin/pkgctl cache
Once it has been updated, log in to ISPmanager as root -> go to the "Server configuration" section-> the Applications (ISPmanager) module and locate "Nginx is a quick and easy WWW server for cashing".
- Click the "Install" icon on the toolbar. In the centos.alt.ru repository choose the version you need (either nginx (0.8) or nginx-stable (0.7)
- Install the selected Nginx version. The server will be configured automatically: Apache will run on port 8080, and Nginx on port 80.
You have successfully installed Nginx as Front-end.
Configuration tips
The /etc/nginx/nginx.conf configuration file in centos.alt.ru does not provide enough worker processes (worker_processes 10). Change this parameter so that the number of processes equal the number of processor kernels on your server (for example, there is normally one kernel on a virtual machine, so you need to run only one process).
Restart Nginx:
/etc/init.d/nginx/restart
or go to ISPmanager -> the Services (ISPmanager) module.
Technical notes
With Nginx configured, the file will be created in /etc/yum.repos.d/centalt.repo. Disable enabled=1 by specifying enabled=0 if you don't want newer software versions to be installed. If necessary, you can update Nginx by specifying the repository manually. For example:
yum --enablerepo=CentALT update nginx
Thereby, you won't suffer from unexpected change of the software version.
