I'm trying to setup my rails server and passenger wont recognize my app giving this error on log:
[error] 1473#1473: *1 "/home/myapp/public/index.html" is not found (2: No such file or directory)
or a 404 error in client.
i've done all troubleshooting possiilities to resolve but nothing.
here is my server block:
server {
listen 80;
server_name mydomaiin.com;
rails_env development;
# Turn on Passenger
passenger_enabled on;
passenger_ruby /home/myapp/.rbenv/versions/2.4.0/bin/ruby;
# Tell Nginx and Passenger where your app's 'public' directory is
root /home/myapp/public;
}
can anyone help me?
thanks
As your root dir is in /home/myapp/myapp, update your server conf:
server {
listen 80;
server_name mydomaiin.com;
rails_env development;
# Turn on Passenger
passenger_enabled on;
passenger_ruby /home/myapp/.rbenv/versions/2.4.0/bin/ruby;
# Tell Nginx and Passenger where your app's 'public' directory is
root /home/myapp/myapp/public;
}
Related
Here is the error.log of nginx server running on ubuntu 12.04.
2014/03/17 12:47:17 [error] 7939#0: *1 open() "/opt/nginx/html/mkl/authentify/signin" failed (2: No such file or directory), client: xxx.xxx.228.66, server: xxx.xxx.109.181, request: "GET /mkl/authentify/signin HTTP/1.1", host: "xxx.xxx.109.181"
In /opt/nginx/conf/nginx.conf, it is configured as following (the only server block in conf):
server {
listen 80;
server_name xxx.xxx.109.181;
root /ebs/www/;
passenger_enabled on;
rails_env production;
passenger_base_uri /mkl;
.....
}
The root of nginx server is pointing to /ebs/www/. However the nginx is accessing the /opt/nginx and throws out no such file error. What causes the problem? Thanks.
The nginx was installed with passenger-install-nginx-module after gem passenger was installed.
Correctly root is your public order from your application:
server {
listen 80;
server_name xxx.xxx.109.181;
root /ebs/www/YOUR_APPLICATION/current/public;
# e.g. root /var/www/vhosts/example.com/httpdocs/example/current/public;
passenger_enabled on;
rails_env production;
passenger_base_uri /mkl;
.....
}
The problem is fixed after adding one more server {} block after the first (only) server block in nginx.conf. In previous version (probably 1.4.x), there were 2 server blocks in nginx.conf. In current version, there is only one server {} block.
More reading about the solution can be found at Why is nginx responding to any domain name? & https://serverfault.com/questions/416064/rails-application-only-showing-nginx-default-page
I have my Phusion Passenger Nginx configured to as below :
server {
listen 80;
server_name blog.abc.com;
passenger_enabled on;
root /app/public;
}
Im about to host the main site abc.com also in this machine. How can I do that (Its a separate app)? Is it possible to add another server block like this :
server {
listen 80;
server_name abc.com;
passenger_enabled on;
root /app2/public;
}
Phusion Passenger author here. Yes. Just add another virtual host block for the other app. It works exactly as expected.
I configured my second app on sub-uri of first app. Below is the nginx conf and settings what i done.
nginx.conf:
server {
listen 80;
server_name localhost;
location / {
root /var/www/demo/public;
passenger_enabled on;
rails_env production;
}
location /test {
root /var/www/demo;
passenger_base_uri /test;
passenger_enabled on;
}
Then add symbolic link:
ln -s /var/www/logger/public /var/www/demo/test
I am already deployed my Rails app with Passenger and Nginx and it's working fine.
Below is my servier configuration:
server {
listen 80;
server_name localhost;
location / {
root /var/www/demo/public;
passenger_enabled on;
rails_env production;
}
Now I want to deploy a second app to a sub URI. Here the documentation is a little unclear.
Could anyone please suggest me what will be the next configuration?
Below is the configuration I am using for my second (Sinatra) application:
location /log {
root /var/www/logger/public;
passenger_base_uri /log;
passenger_enabled on;
}
I am getting "404 Not Found". Please suggest what I am missing here.
Finally it's working!
nginx.conf:
server {
listen 80;
server_name localhost;
location / {
root /var/www/demo/public;
passenger_enabled on;
rails_env production;
}
location /test {
root /var/www/demo;
passenger_base_uri /test;
passenger_enabled on;
}
Then:
ln -s /var/www/logger/public /var/www/demo/test
Thanks for all your help.
Add ^~ before the sub-directory:
location /log
To:
location ^~ /log
I know this is a super-famous error, but i tried quite everything I found here on StackOverflow and on google without being able to solve it.
I have the following configuration:
SLES 11 SP1 on Amazon EC2
nginx 1.2.2
passenger 3.0.15
rails 3
I installed nginx and passenger and set the nginx.conf like this:
http {
passenger_root /usr/lib64/ruby/gems/1.8/gems/passenger-3.0.15;
passenger_ruby /usr/bin/ruby;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root /root/myapp/public;
autoindex on;
passenger_enabled on;
}
}
...
When I access the app from the browser it keeps saying 403 forbidden.
I also run chmod -R 755 on the app folder, on /var and /opt (nginx is in /opt/nginx)
In the logs, the error is:
[error] 5240#0: *1 open() "/root/myapp/public/favicon.ico" failed (13: Permission denied), client: 188.11.5.49, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "ec2-54-247-18-139.eu-west-1.compute.amazonaws.com"
UPDATE: The same error appears also for /root/myapp/public/index.html (which doesn't exist)
[error] 5638#0: *1 "/root/myapp/public/index.html" is forbidden (13: Permission denied), client: 188.11.5.49, server: localhost, request: "GET / HTTP/1.1", host: "ec2-54-247-18-139.eu-west-1.compute.amazonaws.com"
UPDATE 2: Same error also when I run passenger in standalone mode:
You can stop Phusion Passenger Standalone by pressing Ctrl-C.
===============================================================================
2012/08/30 08:31:34 [error] 7834#0: *4 "/root/myapp/public/index.html" is forbidden (13: Permission denied), client: 127.0.0.1, server: _, request: "HEAD / HTTP/1.1", host: "0.0.0.0"
Ok, solved. The problem was that nginx requires read permissions for the app files, and execute permission for everything that goes from the root to the app itself.
Running chmod -R 755 on the root solved the problem.
I found the root cause come from nginx.conf setting.
I change passenger_enabled on and root path in same block (in location /) and restart nginx. The 403 forbidden error solved.
Here is my sample setting:
user redmine;
http {
passenger_root /usr/local/lib/ruby/gems/2.1.0/gems/passenger-4.0.45;
passenger_ruby /usr/local/bin/ruby;
access_log logs/host.access.log;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
# rails server
server {
listen 80;
server_name localhost;
location / {
root /usr/local/redmine-2.5.2/public;
passenger_enabled on;
index index.html index.htm;
}
}
Sam Sheen
If all the folder and file permission are set correctly, please check the configuration:
location ~ ^/redmine(/.*|$) {
passenger_base_uri /redmine;
passenger_app_root /Users/cc/Dropbox/Work/www/redmine;
passenger_enabled on;
}
You should add least add the three line.
Are you missing config.ru?
Missing config.ru caused the error in my case.
Sample Config.ru:
root_dir = File.dirname(__FILE__)
app_file = File.join(root_dir, 'pantube.rb')
require app_file
set :environment, :production #ENV['RACK_ENV'].to_sym
set :root, root_dir
set :app_file, app_file
disable :run
run Sinatra::Application
According to the erro you posted only that file doesn't have the required permission. Try to run chmod 777 /root/myapp/public/favicon.ico
I have simple application which works well on Apache but gives me error 403 after moving to Nginx.
Here is my configuration:
server {
server_name myapp.com;
access_log off;
root /home/www/myapp/public;
autoindex on;
passenger_enabled on;
rails_env production;
}
Nginx is running from www-data user which has r+x permissions to all the folders on the path to the application.
Nginx is 0.8.54 and Passenver is 3.0.5.
Any ideas what can be wrong?
Obviously no reasonable errors in nginx log file (I increased logging level to maximum) and also nothing in rails log files.
You're missing the http port:
server {
listen 80;
...
}