Skip to content

Instantly share code, notes, and snippets.

@fuale
Last active June 17, 2018 13:30
Show Gist options
  • Save fuale/e21ed6c5fc10fe214ad76e4278df0644 to your computer and use it in GitHub Desktop.
Save fuale/e21ed6c5fc10fe214ad76e4278df0644 to your computer and use it in GitHub Desktop.
Nginx config examples
#Для фреймворков - стандартный
server {
server_name [название];
root [путь];
index index.html index.php;
location /
{
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$
{
try_files $uri =404;
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
}
#Для автоматического поиска root директории
server {
server_name ~^(?:www\.)?(?P<host_wo_www>.+)$;
root [путь]/$host_wo_www;
index index.html index.php; #fix 403 error
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000; # Сокет либо порт для Unix систем
#fastcgi_pass unix:/path
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment