0

Hi I am learning how to deploy rails application in VPS, I have followed https://coderwall.com/p/yz8cha this tutorial, and everything worked well, I got some errors and corrected them by searching the net, and all works correctly capistrano deploys the files and folders to VPS and if I am changing any code then after type cap deploy it will changed in VPS also, everything works fine there is no error shown in terminal, But the problem is the nginx server is not running (at initial stage it shows its index page -welcome to nginx), I dont know where may be ther problem occurs and what I have to do any help will be appreciated ,,I am using rails 4.1.4, ruby 2.1.2, capistrano (2.15.5) if its matters..

I dont know which code has to be shown here If you want to see any code I am eager to show you....This is my nginx.conf file

upstream unicorn {
  server unix:/tmp/unicorn.projectname.sock fail_timeout=0;
}

server {
    listen 80 default_server deferred;
  # server_name example.com;
  root /home/administrator/apps/testvps/current/public;

  location ^~ /assets/ {
    gzip_static on;
   expires max;
   add_header Cache-Control public;
   }

   try_files $uri/index.html $uri @unicorn;
   location @unicorn {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_pass http://unicorn;
  }

   error_page 500 502 503 504 /500.html;
   client_max_body_size 20M;
   keepalive_timeout 10;
 }

This is the error I got while nginx -t in VPS terminal

nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log"            failed     (13: Permission denied)
2014/08/01 15:40:35 [warn] 5682#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
2014/08/01 15:40:35 [emerg] 5682#0: open() "/run/nginx.pid" failed (13: Permission denied)
nginx: configuration file /etc/nginx/nginx.conf test failed
4
  • Paste your nginx.conf file content in your question
    – RAJ
    Aug 1, 2014 at 9:58
  • yeah done it Raj, while seeing my nginx folder in vps IN sites-enaled there is one link file for nginx.conf file in rails application but if I am click that one it says link brocken
    – navinspm
    Aug 1, 2014 at 10:02
  • 1
    okay.. let me know output of nginx -t command. Run it on server terminal
    – RAJ
    Aug 1, 2014 at 10:04
  • Posted the command I got form terminal
    – navinspm
    Aug 1, 2014 at 10:12

1 Answer 1

1

As per error shown by nginx -t, user don't have permission to write into nginx log files.

Try running nginx -t as root user sudo nginx -t, if still it shows permission error then try updating permissions:

sudo chown -R www-data:www-data /var/log/nginx;
sudo chmod -R 755 /var/log/nginx;

Edit:

As per our discussion, your nginx configuration is successfully set. Now you are seeing blank page while accessing the app.

You need to add root to your routes.rb file. Rails 4 don't have public/index.html file . So, you are seeing blank page. After setting root you will be able to see your home page.

Your further doubt:

so this is nginx.conf file root /home/administrator/apps/testvps/current/public;

shall i change like this: root /home/administrator/apps/testvps/current;

No, nginx should look to your public directory of the app. it's rails responsibility to navigate the request to root_path as mentioned in routes.rb

7
  • I have executed your codes in my server ,still the same error whether I need to restart my server?
    – navinspm
    Aug 1, 2014 at 10:20
  • 1
    Try nginx -t again and paste error (if any) in comment. If no error, then restart the server
    – RAJ
    Aug 1, 2014 at 10:21
  • I have executed your codes in my server ,still the same error whether I need to restart my server? –
    – navinspm
    Aug 1, 2014 at 10:23
  • okay.. try restarting... Let me know if error is again about permission of /var/log/nginx
    – RAJ
    Aug 1, 2014 at 10:25
  • 1
    Let us continue this discussion in chat.
    – RAJ
    Aug 1, 2014 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.