Update:
Hier gibt es noch eine ausführliches Tutorial, das auch robots.txt usw. umfasst.
Allerdings fehlt der support für Themeplus.
Ich verwende nun eine Mischung aus beidem:
Code:
server {
listen 81;
set $webroot '/Users/simonfakir/dev/contao';
set $errlog "$webroot/logs/nginx.log";
set $acclog "$webroot/logs/access.log";
server_name localhost;
root $webroot;
error_log '/$errlog';
access_log '/$acclog';
index index.php index.html;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# Make sure files with the following extensions do not get loaded by nginx because nginx would display the source code, and these files can contain PASSWORDS!
location ~* \.(tpl|html5|xhtml)$ {
deny all;
}
# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
#
# does not work with themeplus
#
# location ~* \.(jpg|jpeg|png|gif|css|js|ico)$ {
# expires max;
# log_not_found off;
# }
#
# php settings
#
location ~ /(.*\.php)(/.*)$ {
set $script_filename $document_root$1;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $webroot$fastcgi_script_name;
fastcgi_param PATH_INFO $2;
fastcgi_intercept_errors on;
}
location / {
try_files $uri $uri/ /index.php?$args;
rewrite "^/[a-z]{2}/$" /index.php break;
rewrite "^/([a-z]{2})$" /$1/ redirect;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
}
}
Zustätzlich eine leicht modifizierte Version der fastcgi_params :
Code:
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;