WebFaction
Community site: login faq

I've been trying to get Nginx running from source using a debian-style config structure. Everything works fine when my entire config is contained in nginx.conf. However when I move my server config block to sites-available/default with a symlink in sites-enabled I get an error trying to start Nginx.

Here is the Debian-style config:

nginx.conf:

worker_processes 1;

events {
    worker_connections 1024;
}

http {

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    client_max_body_size 5m;

    include /home/${USER}/nginx/conf/mime.types;
    default_type application/octet-stream;

    gzip on;
    gzip_disable \"msie6\";

    include /home/${USER}/nginx/conf/sites-enabled/*;
}

sites-available/default:

server {
    listen       ${listen_port};

    root /home/${USER}/nginx/html/;
    index index.php index.html index.htm;

    server_name _;

    location / {
        index index.html index.html;
    }

    location ~* \.php$ {
        try_files $uri =404;
        fastcgi_index index.php;
        fastcgi_pass unix:/home/${USER}/php-5.3/var/run/php5-fpm.sock;
        include fastcgi_params;
        fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param   SCRIPT_NAME  $fastcgi_script_name;
    }
    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
    }

}

When starting Nginx with this config I get this error:

[emerg] invalid number of arguments in "try_files" directive in /home/hittingsmoke/nginx/conf/sites-enabled/default:15

The line in question is try_files $uri =404; but if I remove this it just goes on to say the same thing about the "fastcgi_param" directive.

If I just literally copy/paste the server block from sites-available/default inside nginx.conf right where the include for my virtual server files is everything runs perfectly.

What am I doing wrong here? Why can't I use multiple config files for Nginx?

asked 27 Jun '13, 14:57

HittingSmoke
4822230
accept rate: 8%


Is 'sites-enabled' and 'sites-available' supposed to be the same value, is that a typo or the real values?

permanent link

answered 27 Jun '13, 19:25

johns
5.4k412
accept rate: 23%

I'm not quite sure what you're asking. Sites-enabled is just a proxy directory to tell Nginx which sites in sites-available are supposed to be active.

To clarify, the way this config works is nginx.conf has an include for conf/sites-enabled/* which loads any config data in files in sites-enabled. conf/sites-enabled has symlinks to identical entries in conf/sites-available which are vhost config files containing Nginx "server" config blocks. So sites-enabled is the same value for sites-available when a site is enabled because sites-enabled just contains a symlink to the file of the same name in sites-available.

Technically the two configs I've tried should parse identically to Nginx. For some reason one is working but one is not.

(27 Jun '13, 19:59) HittingSmoke

Try enable 'debug' level nginx logging for the most verbose info. If this does not indicate the issue submit a support ticket so we can investigate directly.

(27 Jun '13, 20:30) johns

Thanks. I re-compiled with debugging but the error isn't any more verbose. It gives the same feedback at the console and log level.

I'll submit a ticket. This has to be a bug with Nginx in the shared environment. An identical config is working on my dedicated server.

(27 Jun '13, 20:36) HittingSmoke
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×186
×8

question asked: 27 Jun '13, 14:57

question was seen: 4,890 times

last updated: 27 Jun '13, 20:36

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2020 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM