Skip to content
Home » Articles » Racking Up a Serve Project on Phusion Passenger

Racking Up a Serve Project on Phusion Passenger

Deploying a Rack application with Phusion Passenger is a straightforward and efficient way to get your Ruby application up and running on a production server. This article guides you through the steps to deploy a Rack-based application, specifically focusing on the Serve framework, using Phusion Passenger. We’ll cover the setup on both Apache and Nginx, ensuring your Serve project runs smoothly and efficiently.

Prerequisites Rack application with Phusion Passenger

Before we start, ensure you have the following installed:

  • Ruby and RubyGems
  • The Serve gem
  • Phusion Passenger
  • Apache or Nginx

Setting Up Your Serve Project

First, create your Serve project if you haven’t already:

serve create my_project
cd my_project

This command generates a new Serve project in the my_project directory.

Installing Phusion Passenger

Install Passenger as a gem:

gem install passenger

Then, run the Passenger installation command for either Apache or Nginx. Passenger will guide you through the necessary steps:

For Apache:


For Nginx:


Follow the on-screen instructions to configure your web server with Passenger.

Configuring Your Web Server

Apache Configuration

Edit your Apache configuration file (often found at /etc/apache2/sites-available/000-default.conf or a similar location) and add the following, adjusting paths as necessary:

<VirtualHost *:80>
    DocumentRoot /path/to/my_project/public
    <Directory /path/to/my_project/public>
        Allow from all
        Options -MultiViews
        Require all granted

    RackBaseURI /
    <Directory /path/to/my_project>
        Options -MultiViews

Enable the Passenger Apache module and restart Apache:

sudo a2enmod passenger
sudo systemctl restart apache2

Nginx Configuration

For Nginx, edit your Nginx configuration file (often located at /etc/nginx/sites-available/default or a similar location) to include:

server {
    listen 80;

    root /path/to/my_project/public;

    passenger_enabled on;
    passenger_ruby /path/to/ruby;

Replace /path/to/ruby with the output from which ruby, indicating the Ruby interpreter’s location.

Restart Nginx to apply the changes:

sudo systemctl restart nginx

Deploying Your Application

With your web server configured, your Serve project is now accessible via your specified domain. Ensure you’ve populated your Serve project with your application code and views.

Debugging and Logs

Should you encounter issues, consult the logs:

  • Apache: /var/log/apache2/error.log
  • Nginx: /var/log/nginx/error.log

These logs can provide insights into any configuration or application errors.


Q: How do I install Serve?
A: Use the command gem install serve to install Serve.

Q: Can I deploy a Serve project on a subpath?
A: Yes, adjust the RackBaseURI directive for Apache or the root directive for Nginx to point to your project’s public directory.

Q: How do I update my Serve application?
A: Update your application code as needed, and restart Apache or Nginx to apply changes.

Q: What if my application is not loading?
A: Check your server’s error logs for specific messages. Ensure your web server configuration points correctly to your Serve project’s public directory.

Q: How can I secure my Serve project?
A: Consider implementing SSL/TLS encryption, restricting access with .htaccess files or Nginx directives, and ensuring your application code follows security best practices.

Q: Can I use Passenger with Ruby versions managers like RVM or rbenv?
A: Yes, ensure you point to the correct Ruby interpreter in your web server’s configuration, typically found via which ruby.

Q: How do I scale my Serve application with Passenger?
A: Passenger automatically manages application instances. Configure the passenger_max_pool_size directive in Nginx or the PassengerMaxPoolSize directive in Apache to control scaling.

Q: Is it possible to deploy multiple Serve projects on one server?
A: Yes, configure multiple virtual hosts (Apache) or server blocks (Nginx) for each project.

Q: How do I update Passenger?
A: Run gem update passenger and reinstall the Apache/Nginx module as needed.

Deploying your Serve project with Phusion Passenger offers a robust solution for Ruby applications, combining the flexibility of Rack with the power of a dedicated web server. Whether you’re running a small application or a large-scale deployment, this guide provides a solid foundation for getting your Serve project live with minimal hassle.