server { listen 80 default; # - 80 server_name _; # , , set $sathost $host; # sathost . # www if ( $host ~ ^(www\.)?(.+)$ ) { set $sathost $2; } root /var/www/all/$sathost; # index index.php index.html index.htm; # access_log off; # access_log /var/log/nginx/all/$sathost_access.log; # , , . error_log /var/log/nginx/all.error.log error; location / { # if (!-d /var/www/all/$sathost) { # # undefined, /all/undefined set $sathost undefined; rewrite ^ /index.php last; } # rewrite set $rflag 1; # , . flag if (-e $request_filename) { # , set $rflag 0; } if (!-f /var/www/all/$sathost/index.php) { # index.php , , set $rflag 0; } if ($rflag = 1) { # rewrite ^ /index.php last; } # rewrite if (-f $request_filename) { # expires 1h; break; } } location ~ \.php$ { # .php root /var/www/all/$sathost; fastcgi_pass 127.0.0.1:9000; # php-fpm fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/www/all/$sathost/$fastcgi_script_name; include fastcgi_params; break; } location ~ \.htm(l?)$ { # .html .htm # «.parse_html», HTML PHP fastcgi_param SCRIPT_FILENAME /var/www/all/$sathost/$fastcgi_script_name; include fastcgi_params; if (!-f $request_filename) { # .html, # , , rewrite rewrite ^ /index.php last; } if (-f /var/www/all/$sathost/.parse_html) { # # , html php fastcgi_pass 127.0.0.1:9000; } break; } location ~ /\.ht { # , «.ht» - . deny all; } }
Source: https://habr.com/ru/post/142648/
All Articles