Gallery3 on nginx
I then switched my focus to getting some personal sites working, the first being an installation of Gallery3. First hurdle: php.ini settings, in particular short-tags need to be on. No problem, create a .user.ini file with the proper configuration and that's done. Second hurdle: rewrites. Gallery3 uses an index.php dispatcher which requires some rewrite configuration. I'll admit I'm bad at this (rewrites in general but in particular nginx config rewrites/logic) and, after searching and trial/error, I've got it working. Except it uses if () within location.
Here's my config, if anyone can help me migrate to try_files, I'd be appreciative:
server {
listen 80;
server_name site.com;
access_log /var/log/nginx/ionly.servebeer_access.log;
error_log /var/log/nginx/ionly.servebeer_error.log;
root /home/tom/sites/site.com;
index index.php index.html index.htm;
if ($http_host != "site.com") {
rewrite ^ http://site.com$request_uri permanent;
}
include global/restrictions.conf;
# Additional rules go here.
location ~.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/tom/sites/site.com$fastcgi_script_name;
include fastcgi_params;
}
location /gallery3/ {
if (!-e $request_filename) {
rewrite ^/gallery3/index.php/(.+)$ /gallery3/index.php?kohana_uri=$1 last;
rewrite ^/gallery3/(.+)$ /gallery3/index.php?kohana_uri=$1 last;
rewrite ^/gallery3/$ /gallery3/index.php?kohana_uri=/ last;
}
}
}
Edit:
I could not get the suggestions found here
Edit2:
I also saw this
2 Replies
Please, did you find solution for this?
I also have an wordpress website, and gallery as a photo gallery extension of the website, and can´t make it work.
Regards,
Tony
# Site config file
server {
server_name example.com;
root /folder/to/example.com;
include conf.sites/gallery3.conf;
}
# www redirect
server {
server_name www.example.com;
return 301 http://example.com$request_uri;
}
## file gallery3.conf
## Gallery 3 Configuration Based on https://gist.github.com/cite/6419890
index index.php;
client_max_body_size 20M;
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:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_path_info;
include fastcgi_params;
}
}