Skip to content

Instantly share code, notes, and snippets.

@cite
Last active February 10, 2021 19:38
Show Gist options
  • Save cite/6419890 to your computer and use it in GitHub Desktop.
Save cite/6419890 to your computer and use it in GitHub Desktop.
nginx/php-fpm configuration for Gallery3.
[gallery3]
user = vhost-user
group = vhost-group
listen = /tmp/gallery3-example-com.sock
listen.group = www-data
listen.mode = 0660
pm = dynamic
pm.max_children = 5
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.max_requests = 500
# gallery3.example.com definition
server {
server_name gallery3.example.com;
listen 80;
listen [::]:80;
root /srv/www/http-gallery3-example-com;
access_log /var/log/nginx/access-gallery3.example.com.log;
index index.php;
location / {
location ~ /(index\.php/)?(.+)$ {
try_files $uri /index.php?kohana_uri=$2&$args;
location ~ /\.(ht|tpl(\.php?)|sql|inc\.php|db)$ {
deny all;
}
location ~ /var/(uploads|tmp|logs) {
deny all;
}
location ~ /bin {
deny all;
}
location ~ /var/(albums|thumbs|resizes) {
rewrite ^/var/(albums|thumbs|resizes)/(.*)$ /file_proxy/$2 last;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico|ttf)$ {
try_files $uri /index.php?kohana_uri=$uri&$args;
expires 30d;
}
}
location = /index.php {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/tmp/gallery3-example-com.sock;
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_path_info;
include fastcgi_params;
}
}
}
@Malachiel87
Copy link

hi i tried your config, but i see only a blank page.. i know the issue is into php... i amusing this as php block
location = /index.php {
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_path_info;
include fastcgi_params;

@Malachiel87
Copy link

nvm i fixed it but now i cant login... gallery seem to work

@GwynethLlewelyn
Copy link

nvm i fixed it but now i cant login... gallery seem to work

Did you ever manage to login again? Because I cannot...

@GwynethLlewelyn
Copy link

GwynethLlewelyn commented Feb 10, 2021

After years (literally!) of nightmares, I finally found out what was wrong with my configuration...

You have to change this on config.php:

$config["index_page"]=""

... or else, Gallery3 will not work under nginx. Duh! So simple...

Here's the reference (which also cites this very same gist): http://jonamiller.com/2015/02/15/gallery3-on-nginx/

Kudos to @jonmiller for having found a working solution. Gallery3 is now purring like a kitty under PHP 7.4, and soon (hopefully) under 8.0 as well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment