Passenger + Rails + nginx + EC2 Linux AMI Errno::EACCES - ruby-on-rails

I am trying to set up an EC2 Linux AMI with Passenger + Rails. After much trouble, I have gotten nginx to serve out passenger but I am getting an error: Errno::EACCES
I am desperately hoping that this is some stupid setup problem. I am no sysadmin. Any help would be much appreciated and if you would like to see any more information, I am more than willing to comply.
EDIT: I dunno if this will help, but I am running passenger like so (in my applications root directory):
sudo /usr/local/bin/passenger start -a 0.0.0.0 -p 80 -d -e development

I had to chown the directory to ec2-user and then run it with sudo /usr/local/bin/passenger start -a 0.0.0.0 -p 80 -d -e development --user=ec2-user
Why is rails such a nightmare to install!?

Related

How to start a Rails server forever on Ubuntu

I have uploaded my Rails app on my Ubuntu server, where I want to keep my Rails server running so that any one can access it at any time.
I tried the command below to run my app:
rails server --binding=oditek.in -p 8888
Please help me to make this possible.
You can try following option to run the server in background.
rails s -d ## With default Port.
rails s -p 8888 -d ## With Custom port.
Or
nohup rails s &
Or
You can also configure your project with Nginx + Passenger

passenger start standalone with RAILS_ENV=production

I'm trying to run multiple rails apps (different versions) on my server. I followed this post
Phusion Passenger & running multiple Ruby versions
I ran one app outside the pattern with passenger standalone:
passenger start -a 127.0.0.1 -p 3000 -d
But I got this error:
database configuration does not specify adapter
(ActiveRecord::AdapterNotSpecified)
So, this app is on the development environment and I want to run as production mode.
How can I do it?
Solved! I passed now this command:
passenger start -a 127.0.0.1 -p 3000 -d --environment production

Alternate command for passenger start

I have changed my Apache2 port from 80 to 3001
now when i start my rails app i use
rvmsudo rails server -p 80
but I want to run my rails app in passenger nginx that I have already installed. i tried the following but not working
1. rvmsudo passenger start -a 127.0.0.1 -p 80 -e development
2. rvmsudo passenger start -p 80
3. sudo passenger start -e development -p 80
So please let me know what the exact thing i have to do to run my app on port 80 using passenger Thnaks in Advance!
You should use Phusion Passenger's Nginx integration mode. The passenger command only gives you access to the Standalone mode. For more information about the differences between the Nginx integration mode and the Standalone mode, see http://www.modrails.com/documentation/Users%20guide.html.

Unicorn rails server running always

I am using unicorn server for locomotive cms installed on digital ocean in ubuntu 12.04. I am wondering how I keep the server running so when I log out of the ssh session the site stays up and running.
This is currently the command I use to get it running
bundle exec unicorn_rails -p 80
Thanks! in advance
you need to set up unicorn with apache or nginx. here is a guide for apache + unicorn. with that setup you can start and stop server by starting and stopping apache service.
This is a guide on how to setup Unicorn with nginX which I have followed and used numerous times.
https://gist.github.com/billie66/3696537
Run Unicorn via bundler:
bundle exec unicorn -c config/unicorn.rb -E production -D -p 8089
Stop Unicron (if you have followed the guide from above)
kill -9 'cat /path/to/your/app/tmp/pids/unicorn.pid'

How to run rails s -p80 on 80 port?

By default,
rails s #running on 3000 port
Now I want to run it on port 80. So I tried:
sudo rails -s -p80
But it threw an error:
mlzboy#mlzboy-MacBook ~/my/b2c2 $ sudo rails s -p80
sudo: rails: command not found
I used rvm to install ruby & rails. It seems rvm is user specified. Is it not able to find rails in root?
I also tried below code:
mlzboy#mlzboy-MacBook ~/my/b2c2 $ which rails
/home/mlzboy/.rvm/gems/ruby-1.9.2-p0/bin/rails
mlzboy#mlzboy-MacBook ~/my/b2c2 $ sudo /home/mlzboy/.rvm/gems/ruby-1.9.2-p0/bin/rails s -p80
rvmsudo rails server -p 80
Just forward the request from port 80 to 3000 using below command:
sudo iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 3000
Another option is:
rvmsudo rails server -p 80
However please remember to free this port from Apache or other services which consume this port normally. Also, I m not sure giving sudo permission to RVM may have any security issue or not?
Was going to suggest
rails=`which rails` ; sudo $rails server -p 80
but that still tries to use the global gemset and not the project gemset from RVM. So...
Make sure sshd is running on your Mac. (System Prefs => Sharing => Remote Login checked)
Make sure rails s is running on port 3000 as your non-root user
Open a new terminal and...
me=``whoami``; sudo ssh -L 80:127.0.0.1:3000 -l $me -N localhost
(BTW reduce the duplicate `'s to singular ones in the line above, I cannot figure out how escape it properly here.)
The first Password: is your root user, the second is the password for whomever whoami returns.
Though you probably want to install Phusion Passenger and set it up under your local Apache. Unless you are just trying to demo something real quick and this is not a permanent solution of course.
If you are using RVM, and you did the default setup, then you shouldn't use sudo.
Just:
mlzboy#mlzboy-MacBook ~/my/b2c2 $ rails server -p 80
However 80 is a privileged port, so you need to run as root, and you will have follow the instructions for Multi-User installation of RVM.
you can start server on port 80
rails s -p 80
If port 80 does not bind(other processes is not using to port 80).

Resources