8

I have setup the following ngnix config for my Ubuntu 14.04 VPS running HHVM with ngnix:

server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;

root /home/lephenix/main_website;
index.php index.html index.htm;

# Make site accessible from http://localhost/
server_name localhost;
include hhvm.conf;

location / {
    # First attempt to serve request as file, then
    # as directory, then fall back to displaying a 404.
    try_files $uri $uri/ /index.php?q=$uri&$args;
    # Uncomment to enable naxsi on this location
    # include /etc/nginx/naxsi.rules
}
}

Problem is that when I enable this config I get an error from ngnix:

2014/09/07 13:16:01 [emerg] 13584#0: unknown directive "index.php" in /etc/nginx/sites-enabled/default:6

I have looked and this seems to be the correct structure for this configuration. Even when I remove index.php the error then changes to:

2014/09/07 13:17:03 [emerg] 13648#0: unknown directive "index.html" in /etc/nginx/sites-enabled/default:6

I followed the following guide to setup the server: http://webdevstudios.com/2014/07/17/setting-up-wordpress-nginx-hhvm-for-the-fastest-possible-load-times/

Thanks in advance for any help

Chris K
  • 11,996
  • 7
  • 37
  • 65
user1781267
  • 85
  • 1
  • 2
  • 6

1 Answers1

14

It needs to be:

index index.php index.html index.htm

The directive is "index".

Also, the "try_files" is wrong. Change to:

try_files $uri $uri/ /index.php$is_args$args

Also it's much nicer to have the config file indented properly. It makes it much easier to debug.

I suspect the tutorial that you followed is wrong, it's certainly not valid as directives need to be named first before trying to assign something to it.

Pop a note to the tutorial author maybe? It'd be nice for them to correct it so nobody else falls on this one :)

Karl M.W.
  • 728
  • 5
  • 19
  • Thanks for your help!! So I put that in but now i'm getting an error on http://pastebin.com/w1mnJRKX Ngnix is reporting 2014/09/07 13:42:59 [emerg] 1587#0: unknown directive "$args" in /etc/nginx/sites-enabled/default:15 any ideas? – user1781267 Sep 07 '14 at 17:45
  • 1
    You can test nginx config with `nginx -t`. It should tell you something useful. – Rudie Sep 07 '14 at 17:47
  • I think you need a new tutorial to follow :) Nginx is picking up the ";" in "&" as the end of the present directive, so it thinks $args is a new directive. – Karl M.W. Sep 07 '14 at 17:49
  • try_files should be try_files $uri $uri/ /index.php$is_args$args – Karl M.W. Sep 07 '14 at 17:51