So I've recently migrated from apache2/mpm-prefork to nginx/php5-fpm with the help of a couple tutorials, and for the main WordPress site that I host, everything is operational; some tweaking lies ahead certainly, but it's operational nonetheless.
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:
Code:
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 to work. All 404.
Edit2:
I also saw
this, but I don't understand it. Can anybody comment?