
Witajcie.
Wczoraj opisałem jak uruchomić System CMS Drupal na lighttpd – a dziś na NGINX!
1. V-host
server {
listen 80;
server_name www.site.pl;
return 302 http://site.pl$request_uri;
}
server {
listen 80;
server_name site.pl;
access_log /var/log/site.pl/site.pl.access.log;
error_log /var/log/site.pl/site.pl.error.log error;
root /home/www/public_html;
index index.php;
error_page 500 501 502 503 504 /5xx.html; location = /5xx.html { root /home/www/document_errors; internal; }
error_page 403 /403.html; location = /403.html { root /home/www/document_errors; internal; }
location ~* files/styles {
access_log off;
expires 30d;
try_files $uri @drupal;
}
location ~* ^.+.(xsl|xml|js|css|txt)$ {
access_log off;
expires 1d;
try_files $uri @drupal $uri/ =404;
}
location @drupal {
try_files $uri $uri/ /index.php?q=$uri&$args;
include fastcgi.conf;
}
location / {
try_files $uri $uri/ @drupal;
index index.php index.html;
}
location @drupal {
rewrite ^/(.*)$ /index.php?q=$1 last;
}
## Upload in progress
#location ~ (?<upload_form_uri>.*)/x-progress-id:(?<upload_id>\w*) {
#rewrite ^ $upload_form_uri?X-Progress-ID=$upload_id;
#}
#location ^~ /progress {
#upload_progress_java_output;
#report_uploads uploads;
#}
# HOTLINKI
#location ~* \.(gif|png|jpe?g)$ {
#expires 7d;
#add_header Pragma public;
#add_header Cache-Control "public, must-revalidate, proxy-revalidate";
#valid_referers none blocked ~.google. ~.bing. ~.yahoo. ~.unitra. ~.yandex. ~.archive. ~.unitraklub. ~unitraklub. ~.cloudflare. server_names ~($host);
#if ($invalid_referer) {
#rewrite (.*) http://nie-hotlinkuj.site.pl/img.jpg redirect;
#}
#}
## WYŁĄCZNIE WIDOKU NA PLIKI Z "."
location ~ /\.ht { deny all; }
location = /robots.txt {
access_log off;
try_files $uri /index.php?q=$uri;
}
location = /favicon.ico {
expires 30d;
try_files /favicon.ico @empty;
}
location @empty {
expires 30d;
empty_gif;
}
# GENEROWANIE MINIATUREK
location ^~ /files/imagecache/ {
index index.php index.html;
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?q=$1 last;
break;
}
}
# WON DLA CIEKAWSKICH
location ~* ^/wp-admin/? { rewrite ^ http://whatismyipaddress.com/ip/$remote_addr redirect; }
location ~* ^/administrator/? { rewrite ^ http://whatismyipaddress.com/ip/$remote_addr redirect; }
## WYŁĄCZENIE LOGOWANIA PLIKOW STATYCZNYCH
include /etc/nginx/staticfiles.conf;
## PHP-FPM
location ~ .php$ {
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $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_intercept_errors on;
fastcgi_ignore_client_abort off;
fastcgi_connect_timeout 90;
fastcgi_send_timeout 750;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
}
Lub gotowiec 🙂
wget http://pliki.linuxarz.pl/10-2015/nginx-drupal.conf -O /etc/nginx/conf.d/nginx-drupal.conf
- Upload in progress – zakomentowane (jeśli twój nginx ma to wkompilowane to włącz)
- Wyłączona funkcja wyłączonego hotlinkowania – jeśli chce tę funkcję to od-komentuj linijki.
- Pamiętaj aby wykonać edycję z odpowiednim adresem do witryny oraz ścieżek do katalogu/logów itp. 😉
2. Dodatkowy plik z konfiguracją w której wyłączamy logowanie plików statecznych.
wget http://pliki.linuxarz.pl/10-2015/staticfiles.conf -O /etc/nginx/staticfiles.conf
Powiem szczerze! DZIAŁA:)) – zobacz: unitraklub.pl
P.S Czy ja aż tak nie lubię Apache/2 ? 😀