Skip to content

Instantly share code, notes, and snippets.

@Grendel7
Created April 23, 2018 17:55
Show Gist options
  • Save Grendel7/48dee76bc50dbe58784ed978f7f7c7be to your computer and use it in GitHub Desktop.
Save Grendel7/48dee76bc50dbe58784ed978f7f7c7be to your computer and use it in GitHub Desktop.
Example NGINX config file which loads different PHP-FPM apps from subdirectories
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /home/app/html/public;
index index.php index.html index.htm;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location /forum {
alias /home/forum/html;
try_files $uri $uri/ /index.php?uri=$query_string;
}
location ~ /forum/.+\.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php70-fpm-forum.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/forum/html$fastcgi_script_name;
include fastcgi_params;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php70-fpm-app.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment