git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
Pick a Ruby version from rbenv install -l
to install. Then adapt the following command to your version number.
rbenv install 2.2.0
rbenv global 2.2.0
You might need to enlarge swap so this can build Ruby. About 1GB of total memory seems to be needed.
Passenger has to be compiled into Nginx, unless using it Standalone. To take advantage of not configuring reverse proxying, we recompile (which is easy and quick enough).
gem install passenger
passenger-install-nginx-module
The following sections assume you install nginx to /etc/nginx
.
Passenger's installer is well-built so do as it advises. Any suggested permission changes don't make your user files world-readable.
Passenger's generic gem install ignores the need to start Nginx and Passenger on boot. To fix this create a simple systemd service to do so, at /etc/systemd/system/nginx.service
.
[Unit]
Description=Nginx
After=syslog.target network.target
[Service]
Type=forking
ExecStart=/etc/nginx/sbin/nginx
ExecReload=/etc/nginx/sbin/nginx -s reload
[Install]
WantedBy=multi-user.target
Now set this service to start on boot and (if you like) start it now.
sudo systemctl enable nginx.service
sudo systemctl start nginx.service
If you want to run Passenger for a given virtual host, you need to enable it. You can configure Nginx in /etc/nginx/conf/nginx.conf
.
server {
root /PATH_TO_RUBY_APP/public;
passenger_enabled on;
}