Nginx configuration problem

I installed the following ngnix configuration 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 } } 

The problem is that when I enable this configuration, I get an ngnix error message:

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

I looked, and that seems like the right structure for this configuration. Even when I delete 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 have completed the following server setup guide: http://webdevstudios.com/2014/07/17/setting-up-wordpress-nginx-hhvm-for-the-fastest-possible-load-times/

Thank you in advance for your help.

+5
source share
1 answer

It should be:

 index index.php index.html index.htm 

A directive is an "index".

In addition, "try_files" is erroneous. Change to:

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

It is also much nicer to have a formatted configuration file. This makes debugging easier.

I suspect that the textbook you followed is incorrect, it is definitely invalid, as directives must be named first before trying to assign something to it.

Perhaps a note will appear for the author of the textbook? It would be great if they fixed it so that no one gets on it :)

+8
source

Source: https://habr.com/ru/post/1202018/


All Articles