WebFaction
Community site: login faq

I have installed nginx with passenger using home-brew. But its impossible to change the root path of my rails app. Nginx keeps saying:

nginx: [emerg] invalid number of arguments in "root" directive in /opt/nginx/conf/nginx.conf:46

the nginx.conf file is:

   #user nobody;

   worker_processes 1;

   #error_log logs/error.log;

   #error_log logs/error.log notice;

   #error_log logs/error.log info;

   #pid logs/nginx.pid;

   events {

   worker_connections 1024;

   }

   http {

   passenger_root /Users/gabrielmadeira/.rvm/gems/ruby-2.1.0@global/gems/passenger-4.0.42;

   passenger_ruby /Users/gabrielmadeira/.rvm/gems/ruby-2.1.0@filx/wrappers/ruby;

   include mime.types;

   default_type application/octet-stream;

   #log_format main '$remote_addr - $remote_user [$time_local] "$request" '

   # '$status $body_bytes_sent "$http_referer" '

   # '"$http_user_agent" "$http_x_forwarded_for"';

   #access_log logs/access.log main;

   sendfile on;

   #tcp_nopush on;

   #keepalive_timeout 0;

   keepalive_timeout 65;

   #gzip on;

   server {

   listen 80;

   server_name localhost;

   #charset koi8-r;

   #access_log logs/host.access.log main;

   location / {

   root /Users/gabrielmadeira/Google Drive/Apps/Rep/public;

   index index.html index.htm;

   passenger_enabled on;

   rails_env development;

   }

   #error_page 404 /404.html;

   # redirect server error pages to the static page /50x.html

   #

   error_page 500 502 503 504 /50x.html;

   location = /50x.html {

   root html;

   }

   # proxy the PHP scripts to Apache listening on 127.0.0.1:80

   #

   # location ~ \.php$ {

   # proxy_pass http://127.0.0.1;

   #}

   # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

   #

   }


   }

Can anyone help please ?

asked 19 May '14, 13:36

gmadeira
1113
accept rate: 0%

edited 19 May '14, 14:58

seanf
12.2k41836


You have a space in the path for your root directive.

Try changing this...

root /Users/gabrielmadeira/Google Drive/Apps/Rep/public;

... to this ...

root /Users/gabrielmadeira/Google\ Drive/Apps/Rep/public;
permanent link

answered 19 May '14, 15:00

seanf
12.2k41836
accept rate: 37%

Almost there ! Now the error at least changed. Now I get the 404 error - Not found.

But I checked the path /Users/gabrielmadeira/Google\ Drive/Apps/Rep/public; and there is an index.html, despite I will not use it.

(19 May '14, 16:56) gmadeira

Ok, try this instead:

root "/Users/gabrielmadeira/Google Drive/Apps/Rep/public";
(19 May '14, 17:01) seanf

Nope. Same error. I tried with "/Users/gabrielmadeira/Google\ Drive/Apps/Rep/public"; but didn't work either... I can't figure out what is going on. The conf file is like that now:

user  gabrielmadeira staff;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
  #passenger_root /usr/local/opt/passenger;
  passenger_root /usr/local/opt/passenger/libexec/lib/phusion_passenger/locations.ini;
  passenger_ruby /Users/gabrielmadeira/.rvm/gems/ruby-2.1.0@filx/wrappers/ruby;
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  rv.local;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

       location / {
        rails_env          development;
        #root   /Users/gabrielmadeira/Google\ Drive/Apps/Rep/public;
        root "/Users/gabrielmadeira/Google Drive/Apps/Rep/public";
        access_log /Users/gabrielmadeira/Google\ Drive/Apps/Rep/log/nginx_access.log;
        error_log /Users/gabrielmadeira/Google\ Drive/Apps/Rep/log/nginx_error.log;
        passenger_enabled on;
        index  index.html index.htm;
       }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
            passenger_enabled on;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}
permanent link

answered 19 May '14, 17:28

gmadeira
1113
accept rate: 0%

edited 19 May '14, 17:39

seanf
12.2k41836

The error has gone with this configuration:

   server {
           listen       80;
           server_name  rv.local;
           rack_env          development;
           root   "/Users/gabrielmadeira/Google Drive/Apps/Rep/public";
           access_log "/Users/gabrielmadeira/Google Drive/Apps/Rep/log/nginx_access.log";
           error_log "/Users/gabrielmadeira/Google Drive/Apps/Rep/log/nginx_error.log";
           passenger_enabled on; 
   }

but now the application is not showing my show page.... instead a blank page is shown...

permanent link

answered 19 May '14, 17:43

gmadeira
1113
accept rate: 0%

edited 19 May '14, 17:44

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
×25
×5

question asked: 19 May '14, 13:36

question was seen: 4,818 times

last updated: 19 May '14, 17:44

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 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