Здесь я буду собирать полезные nginx конфиги.
Текущий набор конфигов включает конфиги для:
- drupal 6
- drupal 7
Drupal 6
server {
listen 80; # какой порт слушает
root /var/www/drupal/www; # корневая директория
access_log /var/www/drupal/logs/access.log; #расположение логов данного хоста
error_log /var/www/drupal/logs/error.log;
server_name drupal;
charset utf-8;
location = / { rewrite . /index.php last; }
location / { rewrite ^(.*)$ /index.php?q=$1 last; }
location = /index.php {
fastcgi_pass 127.0.0.1:9001;
include /etc/nginx/fastcgi_params;
}
# To retrieve this script periodically use: curl -sH "Host: my.host.tld" http://localhost/cron.php
location = /cron.php {
allow 127.0.0.1;
deny all;
fastcgi_pass 127.0.0.1:9001;
include /etc/nginx/fastcgi_params;
}
# Static content
location = /robots.txt { if (-f $document_root/sites/default/robots.txt) { rewrite . /sites/default/robots.txt; } break; }
location ~ ^(/sites/all)?/(modules|themes)/.*\.(css|js|png|gif|jpg)$ { break; }
location /misc/ { break; }
location /sites/default/files/ { break; } # Depending on Drupal configuration (Administer -> File system)
# Imagecache (http://drupal.org/project/imagecache)
location /sites/default/files/imagecache/ {
if (-f $request_filename) { break; }
rewrite ^(.*)$ /index.php?q=$1 last;
}
# **** Comment out this location after installing/updating Drupal ****
location ~ ^/(install|update)\.php$ {
allow 127.0.0.1;
deny all;
fastcgi_pass 127.0.0.1:9001;
include /etc/nginx/fastcgi_params;
}
# ********************************************************************
}
Nginx конфиг для drupal 7 (drupal7.conf)
server {
listen 80;
root /var/www/drupal7/www;
access_log /var/www/drupal7/logs/access.log;
error_log /var/www/drupal7/logs/error.log;
server_name drupal7;
charset utf-8;
location = / { rewrite . /index.php last; }
location / { rewrite ^(.*)$ /index.php?q=$1 last; }
location = /index.php {
fastcgi_pass 127.0.0.1:9001;
include /etc/nginx/fastcgi_params;
}
# To retrieve this script periodically use: curl -sH "Host: my.host.tld" http://localhost/cron.php
location = /cron.php {
allow 127.0.0.1;
deny all;
fastcgi_pass 127.0.0.1:9001;
include /etc/nginx/fastcgi_params;
}
# Static content
location = /robots.txt { if (-f $document_root/sites/default/robots.txt) { rewrite . /sites/default/robots.txt; } break; }
location ~ ^(/sites/all)?/(modules|themes)/.*\.(css|js|png|gif|jpg)$ { break; }
location /misc/ { break; }
location /sites/default/files/ { break; } # Depending on Drupal configuration (Administer -> File system)
# Imagecache (http://drupal.org/project/imagecache)
location /sites/default/files/imagecache/ {
if (-f $request_filename) { break; }
rewrite ^(.*)$ /index.php?q=$1 last;
}
# **** Comment out this location after installing/updating Drupal ****
location ~ ^/(install|update)\.php$ {
allow 127.0.0.1;
deny all;
fastcgi_pass 127.0.0.1:9001;
include /etc/nginx/fastcgi_params;
}
# ********************************************************************
}
nginx conf для jeka.by
server {
listen 80; # какой порт слушает
root /var/www/jeka/www; # корневая директория
access_log /var/www/jeka/logs/access.log; #расположение логов данного хоста
error_log /var/www/jeka/logs/error.log;
server_name jeka;
location ^~ / {
try_files $uri @dynamic;
}
location = /index.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_param APPLICATION_ENV test;
}
location @dynamic {
rewrite .* /index.php last;
}
}