Nginx

From Void Linux Wiki
Jump to: navigation, search

Nginx is a reliable and powerful web server with a low memory foot print.

Installation

Install the nginx package and enable the provided service.

# xbps-install -S nginx
# ln -s /etc/sv/nginx /var/service

The default location for web pages will be in /usr/share/nginx/html.

Configuration

The default configuration file for nginx will be in /etc/nginx/nginx.conf

Server Blocks

Server blocks make it possible for one server to resolve multiple domains similar to apache's virtual hosting feature. For this feature to work it is necessary to make sure that the domain is set up properly. If the domain names do not resolve to the machine's IP address this will not work. The domain name can be set using applications such as bind or dnsmasq.

A sample server block configuration might look as follows:

server {
 listen        80;
 server_name   site1.com;

 location / {
  root /usr/share/nginx/site1;
  index index.html index.htm;
 }

server {
 listen        80;
 server_name   site2.com

 location / {
  root /usr/share/nginx/site2;
  index index.html index.htm;
 }
}


FastCGI

php-fpm