On a EC2 with ubuntu 14.04 with nginx/passenger/rails came with this log on nginx:
App 31063 stderr: * ERROR *: Cannot execute /usr/local/lib/ruby:
Permission denied (13)
App 31065 stderr: /etc/profile.d/rbenv.sh: line 3: rbenv: command not
found nginx conf is:
worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
passenger_root /usr/local/lib/ruby/gems/2.2.0/gems/passenger-5.0.18;
passenger_ruby /usr/local/lib/ruby;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name teste.com;
root /home/ubuntu/teste/current/public;
passenger_enabled on;
rails_env production;
access_log logs/access.log;
location ~ ^/(assets)/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
}
someone cloud give some light? thank's
Execute in Terminal
sudo chmod o+x "/root"
Resolve this problem!
* ERROR *: Cannot execute /root/.rbenv/versions/2.2.3/bin/ruby Phusion Passenger Permission denied (13)
Phusion Passenger nginx centos
http://oki2a24.com/2014/02/08/try-to-install-ruby-and-redmine/
passenger_ruby should point to the ruby command itself. Yours appears to point to a directory /usr/local/lib/ruby/ (based partly on the passenger_root path).
https://www.phusionpassenger.com/library/config/nginx/reference/#passenger_ruby
Try changing passenger_ruby to /usr/bin/ruby , or whatever your path is. "which ruby" would give you the path, if it's in your PATH environment variable.
Related
Nginx runs fine with an empty sites-enabled directory, but then I create the symlink with
sudo ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/,
and restarting nginx fails. I type nginx -T, and the culprit is
2020/06/29 20:24:19 [emerg] 4087#4087: duplicate upstream "appname" in /etc/nginx/sites-available/default:1
, which is clearly caused my symolink, so I'm not sure what I did wrong.
The original problem I'm trying to fix is getting my EC2 instance to serve my API instead of the default "Welcome to nginx!" page.
Deleting the symlink lets nginx run normally. Here is a shortened version of my output of nginx -T when it works:
# configuration file /etc/nginx/nginx.conf:
user root;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 20000;
# multi_accept on;
}
http {
disable_symlinks off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
...
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
include /etc/nginx/sites-available/*;
...
}
# configuration file /etc/nginx/sites-available/default:
upstream appname {
# Path to Puma SOCK file, as defined previously
server unix:/home/ubuntu/appname/shared/sockets/puma.sock fail_timeout=0;
}
server {
listen 80;
listen [::]:80 ipv6only=on default_server;
# server_name domain.tld www.domain.tld;
server_name ec2...compute.amazonaws.com www.ec2...compute.amazonaws.com
root /home/ubuntu/appname/public;
try_files $uri/index.html $uri #app;
location #app {
proxy_pass http://ec2...us-east-2.compute.amazonaws.com;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
access_log /home/ubuntu/appname/log/nginx.access.log;
error_log /home/ubuntu/appname/log/nginx.error.log;
}
location ~* ^/assets/ {
# Per RFC2616 - 1 year maximum expiry
expires 1y;
add_header Cache-Control public;
# Some browsers still send conditional GET requests if there's a
# Last-Modified header or an ETag header even if they haven't
# reached the expiry date sent in the Expires header.
add_header Last-Modified "";
add_header ETag "";
break;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
I'm pretty new to this so I assume it's something basic, but I've been on this for hours and I'm not sure what to do. Also, if it helps, I'm using puma for my application server.
I'm getting a "We're sorry, but something went wrong" screen upon attempting to deploy. It was previously working fine, however when I tried to update it, I ran into this issue. This is my first time deploying anything, and I'm still not exactly sure what I'm doing so I would really appreciate some input as to what I'm doing incorrectly.
I get the following error from unicorn.log
I, [2018-10-01T19:54:53.470419 #4905] INFO -- : unlinking existing
socket=/home/deploy/production/appName/tmp/sockets
/bcrypt_unicorn.todo.sock
I, [2018-10-01T19:54:53.470635 #4905] INFO -- : listening on addr=/home/deploy/production/appName/tmp/sockets/bcrypt_unicorn.todo.sock fd=10
I, [2018-10-01T19:54:53.470737 #4905] INFO -- : worker=0 spawning...
I, [2018-10-01T19:54:53.471045 #4905] INFO -- : worker=1 spawning...
I, [2018-10-01T19:54:53.471397 #4905] INFO -- : master process ready
I, [2018-10-01T19:54:53.476589 #4908] INFO -- : worker=0 spawned pid=4908
I, [2018-10-01T19:54:53.476714 #4908] INFO -- : Refreshing Gem list
I, [2018-10-01T19:54:53.477787 #4910] INFO -- : worker=1 spawned pid=4910
I, [2018-10-01T19:54:53.477910 #4910] INFO -- : Refreshing Gem list
I, [2018-10-01T19:54:59.740522 #4908] INFO -- : worker=0 ready
I, [2018-10-01T19:54:59.744825 #4910] INFO -- : worker=1 ready
and the following error from /var/log/nginx/error.log:
2018/10/01 20:00:41 [crit] 5067#5067: *2 connect() to unix:/home/deploy
/production/appName/tmp/sockets/bcrypto_unicorn.todo.sock failed
(2: No such file or directory) while connecting to upstream, client:
77.75.77.32, server: , request: "GET /genres/gaming HTTP/1.1", upstream:
"http://unix:/home/deploy/production/appName/tmp/sockets
/bcrypto_unicorn.todo.sock:/genres/gaming", host: "appName.com"
I restarted Nginx with
sudo service nginx restart
Reload the updated configuration
sudo nginx -s reload
Then stopped the running Unicorn process
ps aux | grep "unicorn master"
kill -9 PID
Then pulled updated code to deploy
git status
git stash save -u quick-fix
git pull origin master
git stash apply
Then migrated the db
RAILS_ENV=production rake db:migrate
RAILS_ENV=production rake assets:precompile
Then finally restarted Unicorn
bundle exec unicorn -E production -c config/unicorn.rb -D
My unicorn.rb file is as follows:
app_path = "/home/deploy/production/appName"
working_directory app_path
pid app_path + "/tmp/pids/unicorn.pid"
stderr_path app_path + "/log/unicorn.log"
stdout_path app_path + "/log/production.log"
listen app_path + '/tmp/sockets/bcrypt_unicorn.todo.sock'
worker_processes 2
timeout 65
appName/config/nginx.conf
upstream unicorn {
server unix:/tmp/sockets/bcrypto_unicorn.todo.sock fail_timeout=0;
}
server{
listen 80 default deferred;
root /home/deploy/production/appName/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 403 404 /404.html;
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
and /etc/nginx/nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml applicati$
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
/etc/nginx/sites-enabled/bcrypto
upstream bcrypto_unicorn {
server unix:/home/deploy/production/appName/tmp/sockets/bcrypto_unicorn.todo.sock fa$
}
server {
listen 80 default deferred;
root /home/deploy/production/appName/public;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri #bcrypto_unicorn;
location #bcrypto_unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://bcrypto_unicorn;
}
error_page 422 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 60;
}
Can someone please point me in the direction of what I'm doing incorrectly here?
Firstly, check your tmp/sockets folder to see whether its exists or not. If not, create the folder with following command
mkdir /home/deploy/production/appName/tmp/sockets
Then, change your socket to the same path with nginx by modify your unicorn.rb
listen app_path + '/tmp/sockets/bcrypt_unicorn.todo.sock'
Lastly, restart unicorn
bundle exec unicorn -E production -c config/unicorn.rb -D
The problem is that Nginx is looking for the socket in a different place that Unicorn has set it.
Nginx is trying to find the socket at:
/home/deploy/production/appName/tmp/sockets/byc2-master_unicorn.todo.sock while the Unicorn config is setting it to /tmp/appName_unicorn.todo.sock
To solve the problem both paths must be the same. So you need to place the same path in the upstream directive of /etc/nginx/sites-enabled/bcrypto and the one defined by the listen directive in unicorn.rb
Then restart Unicorn and reload Nginx
When I try restart nginx and write in console this command
nginx -t
I have an error:
nginx: [emerg] a duplicate default server for 0.0.0.0:80 in /etc/nginx/sites-enabled/default.save:20
nginx: configuration file /etc/nginx/nginx.conf test failed
sites-enabled/default
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name localhost;
passenger_enabled on;
rails_env production;
root /home/hh/public;
access_log /var/log/nginx/host.access.log;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
nginx.conf
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
One hour ago everything worked fine, but after restart nginx I have this issue.
If you look at /etc/nginx/sites-enabled/ you see two files, default.save and default just remove one of them
sudo rm -rf /etc/nginx/sites-enabled/default.save
you should remove default_server on default conf file.
I'm hosting an API for a mobile app developed in Rails 4 on DigitalOcean using the One-Click Ubuntu 12.10 Installation droplet. Therefore nginx and Unicorn are preconfigured and running. When I try to open a file from Rails public folder on my web browser, it works.
But when I try to use any of the other paths defined in the routes.rb file I don't get any answer. My requests are loading until they time out. This changes when I type rails s -e production on the server – then everything works as expected. Therefore it must be a problem with nginx or something. What am I missing?
Here's my nginx sites-enabled/default file content (I don't know if that's the thing to look for, but maybe):
server {
listen 80;
root /home/rails/public;
server_name _;
index index.htm index.html;
location / {
try_files $uri/index.html $uri.html $uri #app;
}
#location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|mid$
location ~* ^.+\.(jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rt$
try_files $uri #app;
}
location #app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server;
}
}
UPDATE: Here is my nginx.conf file in case this helps:
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events { worker_connections 1024; }
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
gzip_types text/plain text/xml text/css text/comma-separated-values;
upstream app_server { server 127.0.0.1:8080 fail_timeout=0; }
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
UPDATE 2: And here my unicorn.conf file:
listen "127.0.0.1:8080"
worker_processes 2
user "rails"
working_directory "/home/rails"
pid "/home/unicorn/pids/unicorn.pid"
stderr_path "/home/unicorn/log/unicorn.log"
stdout_path "/home/unicorn/log/unicorn.log"
I had the same issue and running bundle install on the root of my app (on digitalocean droplet) resolved my issue. I think I have to build that into my capistrano script
Rails on Phusion Passenger with Nginx not allow uploading files of size > 2G.
During upload I get 500 error and a RackMultipart file in /tmp folder of size 2G exactly.
nginx.conf:
worker_processes 2;
timer_resolution 100ms;
worker_priority -5;
error_log /opt/vhod/webapp/shared/log/nginx_error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
passenger_root /home/vhod-admin/.rbenv/versions/1.8.7-p370/lib/ruby/gems/1.8/gems/passenger-3.0.19;
passenger_ruby /home/vhod-admin/.rbenv/versions/1.8.7-p370/bin/ruby;
passenger_max_pool_size 3;
passenger_pool_idle_time 1200;
passenger_spawn_method smart;
passenger_friendly_error_pages on;
passenger_log_level 1;
passenger_debug_log_file /opt/vhod/webapp/shared/log/passenger_debug.log;
include mime.types;
default_type application/octet-stream;
sendfile on;
client_max_body_size 0;
proxy_max_temp_file_size 0;
proxy_read_timeout 360s;
keepalive_timeout 70;
server {
listen 443;
server_name vhod;
charset utf-8;
root /opt/vhod/webapp/current/redmine/public;
passenger_enabled on;
passenger_use_global_queue on;
passenger_min_instances 1;
rails_env production;
ssl on;
ssl_certificate cert.pem;
ssl_certificate_key cert.key;
ssl_protocols SSLv3 TLSv1;
if (-f /opt/vhod/webapp/shared/system/maintenance.html) {
rewrite ^(.*)$ /opt/vhod/webapp/shared/system/maintenance.html last;
break;
}
}
}
Everything works only without nginx. When i run mongrel/thin/webrick server with the application. So, the passenger is the latest version, 3.0.19, nginx is 1.2.6.
What's the matter?
This is a possible bug in Phusion Passenger, which has been solved in version 4.0.0 RC 4.
Set the client_max_body_size to > 2000m.
http://wiki.nginx.org/HttpCoreModule#client_max_body_size