Nginx

nginx is a robust, small and high performance web server and reverse proxy server. It is a good alternative to the popular available web servers like Apache and lighttpd.

Installation
Install :

USE flags
Add nginx to the default runlevel:

Configuration
The nginx configuration is handled by. Example 1 shows a single-site access, without dynamic capabilities (such as PHP).

Start nginx:

Verify nginx is running and responding as configured above:

Enabling PHP support
Add following lines to your nginx configuriation to enable PHP support. In this example nginx is exchanging information with the PHP process via a UNIX socket. {{File|/etc/nginx/nginx.conf|Example 2 - Enabling PHP support| ... http{ ...   server { ...           location ~ \.php$ { include /etc/nginx/fastcgi.conf; fastcgi_pass unix:/var/run/php-fpm.socket; } } }}

Additionally it is needed to build PHP with FastCGI Process Manager (php-fpm) support enabled. Add the fpm USE flag to the package:

Rebuild php with the new USE flag enabled.

Review the configuration, add following line:

Start the php-fpm daemon:

Add php-fpm to the default runlevel

Reload nginx with changed configuration

IP access list
Example 4 shows how to allow access to a particular site /nginx_status only to certain IP networks, or hosts f.e. 192.0.2.1 198.51.100.0/24 127.0.0.1. IP addresses are in CIDR notation, see definition example below:

Troubleshooting
Get general information using following troubleshooting commands. Check if the nginx process is running:

Verify nginx daemon is listening on TCP port 80:

External resources

 * nginx Wiki
 * Gentoo Community wiki article