Habari with Nginx problems

Skip to first unread message

Vladimir Nikšić

Sep 7, 2014, 8:55:36 AM9/7/14
to habar...@googlegroups.com
Hi, I'm having an embarrassing issue with habari and nginx. I'm running nginx with php 5.5.9. I have a domain setup, and I want the blog to be something like domain.com/blog, and not a separate vhost. This is the nginx vhost config I'm using:

server {
  listen x.x.x.x:80;
  server_name domain.net www.domain.net;
  root /home/www/domain.net/htdocs;
  error_log /home/www/domain.net/logs/error.log;
  access_log /home/www/domain.net/logs/access.log;
  index index.php index.html index.htm;

location /blog/ {
    try_files $uri $uri/ /blog/index.php?$args;

  location ~ \.php$ {
    include fastcgi_params;
    fastcgi_intercept_errors on;
    fastcgi_pass   unix:/var/run/php5-fpm.sock;
  location ~ /\.ht {
    deny  all;

As to my knowledge this should work. However, when visiting domain.net/blog, the browser simply initiates a download of a file name "download" which is the index.php. For example, a simple php script like a hello world works great, or a phpinfo page works great. When I try to visit directly domain.net/blog/index.php then the installation starts, however soon runs into problems. I'm guessing it has something to do with the try_files. Can someone please give me a hint? :)

Bryce Campbell

Sep 8, 2014, 10:35:34 AM9/8/14
to habar...@googlegroups.com
Not too sure about nginx, but the document root seems to be wrong to me, though that might be because I use apache. I would expect htdocs to come before the domain name, but I will check for nginx documentation on that, which you definitely check as well.

Sent from my iPad
To post to this group, send email to habar...@googlegroups.com
To unsubscribe from this group, send email to habari-dev-...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/habari-dev
You received this message because you are subscribed to the Google Groups "habari-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to habari-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Chris Meller

Sep 8, 2014, 1:00:41 PM9/8/14
to Habari Dev
The root is relatively arbitrary, so as long as that’s the right location and structure, that’s all good.

Vladimir: Can you post your fastcgi_params file?

Also, it’s unrelated, but I’d recommend changing /blog/index.php?$args to /blog/index.php$is_args$args

When you use the straight ?$args version PHP thinks you’ve always got a query string (which is technically true, it’s just empty), so you can end up getting our “We saved your position when your session timed out!” notice every time you hit the admin, even if you didn’t have anything to save. $is_args will evaluate to a ? if there is a query string, otherwise it’s an empty string, which solves that problem.

Vladimir Nikšić

Sep 12, 2014, 9:25:35 AM9/12/14
to habar...@googlegroups.com
Sorry for the late reply. Turns out it was a matter of cache on chromium, as it worked from firefox or chromium incognito. After clearing the cache it worked as intended. 

I didn't want the habari installation to be in the document root, but a subdirectory. For future reference, this is what I used:

Chris Meller

Sep 12, 2014, 10:50:28 PM9/12/14
to Habari Dev
No worries, glad you got it worked out!

I’d still recommend changing ?$args to $is_args$args, though!

Happy Habari’ing.

Reply all
Reply to author
0 new messages