Nginx: Difference between revisions
From TykWiki
Jump to navigationJump to search
Created page with "nginx is my new favourite webserver. This page contains my notes for when I am installing it on a new machine (well, in a new jail ofcourse). == Modules == I generally instal..." |
(No difference)
|
Revision as of 22:39, 14 January 2012
nginx is my new favourite webserver. This page contains my notes for when I am installing it on a new machine (well, in a new jail ofcourse).
Modules
I generally install nginx with as few modules as possible enabled:
[tykling@vpnwiki /usr/ports/www/nginx]$ make showconfig | grep "=on"
IPV6=on "Enable IPv6"
HTTP_MODULE=on "Enable HTTP module"
HTTP_REWRITE_MODULE=on "Enable http_rewrite module"
Config
After installing nginx I replace the default config with something more sensible, like this example for a mediawiki install:
worker_processes 1;
error_log /usr/local/www/logs/error.log;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type text/plain;
log_format main '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for"';
error_log /usr/local/www/logs/vpnwiki.ryst.cn.dom.error.log;
sendfile off;
keepalive_timeout 65;
server {
listen 80 default_server;
listen [::]:80 default_server;
access_log /usr/local/www/logs/vpnwiki.ryst.cn.dom.access.log main;
server_name wiki.tyk.nu;
root /usr/local/www/mediawiki;
client_max_body_size 5m;
client_body_timeout 60;
//mediawiki specific config
location / {
try_files $uri $uri/ @rewrite;
index index.php;
}
location @rewrite {
rewrite ^/(.*)$ /index.php?title=$1&$args;
}
location ^~ /maintenance/ {
return 403;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/php/php-fpm.socket;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
try_files $uri /index.php;
expires max;
log_not_found off;
}
location = /_.gif {
expires max;
empty_gif;
}
location ^~ /cache/ {
deny all;
}
location /dumps {
root /usr/local/www/mediawiki/local;
autoindex on;
}
}
}