
Ruby on Rails has become one of the most popular web development frameworks for building dynamic web applications quickly and efficiently. Many developers want to deploy their Rails applications to a production server, but choosing the right hosting environment can be confusing. This comprehensive guide walks you through the process of running Ruby on Rails on shared hosting with DirectAdmin control panel, which AsiaGB offers, while helping you understand when a VPS might be a better choice for your project.
What is Ruby on Rails
Ruby on Rails, commonly known as Rails, is a web application framework written in the Ruby programming language that provides a complete structure for building database-driven web applications. Rails emphasizes convention over configuration (CoC) and the DRY (Don't Repeat Yourself) principle, allowing developers to write less code while achieving more functionality. The framework comes with built-in support for MVC (Model-View-Controller) architecture, database migrations, automatic routing, and numerous other features that accelerate development. Rails powers popular applications and websites across e-commerce, social networks, content management systems, and enterprise applications.
Understanding Shared Hosting Limitations for Rails
This is where many developers encounter their first challenge. Shared hosting environments like AsiaGB's are primarily designed to host PHP applications such as WordPress and Joomla, where the application runs within Apache or Nginx as a module. Rails applications work differently—they need a separate application server (like Passenger, Puma, or Unicorn) that manages the Ruby process independently. While SSH access may be available on some shared hosting accounts, actually running a Rails app requires server-level configuration that most hosting providers reserve for VPS or dedicated server customers. Before committing to shared hosting for Rails, you need to verify these critical points with your hosting provider:
- Is Phusion Passenger installed with Ruby support (not just PHP)
- Can Passenger be configured to serve Rails applications from the public_html directory or a subdirectory
- What Ruby versions are available (2.6, 2.7, 3.0, 3.1 or newer)
- Are build tools (gcc, make, ruby-dev headers) available for compiling native gem extensions
- Is there any resource throttling that might limit Rails application memory or CPU usage
Core Requirements for Rails on Shared Hosting
Before you attempt to deploy a Rails application to any shared hosting environment, ensure these fundamental components are in place and accessible to your account. The absence of any one of these elements can prevent your Rails application from running properly, so verification is essential. First, SSH access is mandatory because you need terminal access to run installation commands, bundle dependencies, and execute database migrations. Without SSH, you're limited to uploading files via FTP and using DirectAdmin's GUI, neither of which provides the necessary control for Rails deployment. Second, a Ruby runtime version 2.6 or higher is required, with versions 2.7, 3.0, or 3.1 being ideal for modern Rails applications. Many shared hosting providers still offer older Ruby versions that no longer receive security updates and are incompatible with recent Rails releases.
Third, Bundler must be installed and functional, as this gem dependency manager is essential for installing and managing all gems your Rails application requires. Fourth, you need an application server—typically Phusion Passenger, which integrates with Apache or Nginx and can serve Rails applications directly. Without an app server properly configured for Ruby, your Rails code cannot execute regardless of how correctly it's installed. Fifth, a database is crucial: Rails relies on databases like MySQL or PostgreSQL for data storage. AsiaGB shared hosting includes MySQL, but you should verify the version and that Rails can connect to it. Finally, Git installation is beneficial but optional—if your team uses version control and deploys from GitHub, you'll want Git available for cloning repositories and pulling updates.
Step-by-Step Installation Process
Assuming your hosting provider confirms support for Rails and Passenger is installed, here's how the deployment typically works. Connect to your server via SSH using your DirectAdmin credentials and terminal application (Terminal on Mac/Linux, PuTTY on Windows). First, verify your Ruby installation by running ruby -v to see the version currently available. If the version is too old, ask your hosting provider about alternative versions or rbenv setup. Next, install Bundler if it's not already present by running gem install bundler. This creates a local gem installation in your user directory.
Then, place your Rails application code in the appropriate directory. If this is a subdomain, you might use a folder like ~/public_html/myapp or check with your provider about Rails-specific directory structures. Inside your application directory, run bundle install to install all gem dependencies listed in your Gemfile. This step may fail if any gems have native extensions and the required build tools aren't available. Next, create or edit your config.ru file which Passenger uses to start your Rails application. Configure your config/database.yml file with the correct MySQL credentials provided by your hosting account. Run bundle exec rake db:migrate to create or update your database schema. Finally, restart Passenger through your DirectAdmin control panel or by running touch tmp/restart.txt in your app directory.
Common Obstacles and How to Handle Them
Several predictable challenges emerge when deploying Rails to shared hosting environments. The most prevalent issue is Passenger not being configured for Ruby support—if your app returns a 500 error or shows a Passenger-related error, this is likely the cause. Contact support to confirm Ruby is enabled in Passenger configuration. Another frequent problem involves native extensions in gems like mysql2, nokogiri, or image_processing. These gems require C compilers and development headers that shared hosting blocks at the system level. If you encounter compilation errors during bundle install, and the gem requires native extension compilation, your options are limited to: installing a pre-compiled version if available, using an alternative pure-Ruby gem, or migrating to VPS hosting.
Memory constraints represent another potential issue—Rails applications typically consume more RAM than static HTML sites, and shared hosting may have per-account limits. If your app starts consuming excessive memory, the hosting provider's system may automatically terminate it or throttle performance. Background job processing presents yet another hurdle: gems like Sidekiq or Resque require a message queue (Redis) that shared hosting almost never provides. You can use cron jobs to run Rake tasks, but this only allows scheduled jobs, not real-time workers. Database performance can also suffer on shared hosting if the server is overloaded with other customers' databases, causing slow queries.
Why VPS is Often the Smarter Choice
After wrestling with these limitations, many Rails developers eventually migrate to a VPS—and this often proves to be the right decision. With a Linux VPS from AsiaGB starting at just 500 baht per month, you gain several critical advantages. You get full root access, meaning you can install any Ruby version using rbenv or RVM, allowing you to upgrade independently from your hosting provider. You can install Phusion Passenger, Puma, Unicorn, or any other app server your application requires. You can install system dependencies and build tools, making native gem compilation possible. You can run background job processors like Sidekiq with Redis or other message brokers. You can install monitoring tools, logging systems, and security software. You can configure Nginx or Apache exactly as your application needs.
AsiaGB's VPS infrastructure includes automatic backups twice monthly, which protects your application and data automatically without additional cost. The 99% uptime guarantee means your Rails applications have reliable availability. With datacenters in Thailand (CS Loxinfo infrastructure) and Singapore (OVHcloud), you can choose location based on your target audience's geography, ensuring faster response times and better SEO performance for local searches.
Deployment Planning Checklist
Whether you choose shared hosting or VPS for your Rails application, follow this comprehensive planning process to ensure smooth deployment. Start by developing and thoroughly testing your Rails application on your local machine, ensuring all features work correctly and database migrations execute without errors. Push your code to version control (GitHub, GitLab) so you have a reliable backup and deployment mechanism. Research your hosting provider's specific requirements and confirm they support your application's dependencies and Ruby version. Test the complete deployment process on a staging environment (a secondary hosting account or VPS) before deploying to production, working through all potential issues in this low-stakes environment. Document any custom configuration required for your specific application. Only after successful staging deployment should you proceed to production, having full confidence in the process.
Performance Considerations and Optimization
Rails applications on shared hosting may experience performance issues due to resource contention and limited caching options. Consider implementing HTTP caching headers to reduce unnecessary re-rendering of pages. Use fragment caching in your views to cache expensive computations. Implement database query optimization and consider adding indexes to frequently-searched columns. Use asset precompilation and enable gzip compression. If your shared hosting provider offers Redis caching, configure Rails session storage to use Redis instead of the database. Monitor your application's memory usage and optimize any queries that produce large result sets. If shared hosting performance proves insufficient during testing, this confirms that VPS would be a worthwhile investment.
Security Best Practices for Hosted Rails Apps
Regardless of your hosting choice, secure your Rails application properly. Keep Rails and all gems updated to latest patch versions—run bundle update regularly and review security advisories. Use environment variables for sensitive configuration (database passwords, API keys) rather than hardcoding them. Enable HTTPS/SSL (AsiaGB provides free SSL certificates with all hosting plans) and configure Rails to enforce HTTPS. Set secure database permissions so only your Rails application can access the database. Implement rate limiting to prevent abuse and brute-force attacks. Keep backups of your database and code separate from the web server. Review Rails security guides and follow OWASP best practices. Consider using a Web Application Firewall (WAF) if available through your hosting provider.
Frequently Asked Questions
Does AsiaGB shared hosting support Ruby on Rails?
AsiaGB shared hosting with DirectAdmin provides SSH access and Ruby runtime capability. However, running a full Rails application requires Phusion Passenger for Ruby or another app server that supports long-running processes. Most shared hosting environments do not have Passenger configured for Ruby applications, making VPS a more practical choice for production Rails deployments. Contact AsiaGB support to confirm Ruby/Passenger availability on your specific account.
Can I install Ruby gems with native extensions on shared hosting?
Installing gems with native extensions is extremely difficult on shared hosting. Native extensions require compilation of C/C++ code using build tools like gcc, make, and ruby-dev, which shared hosting providers typically do not allow users to install. If your Rails application depends on such gems (like mysql2, nokogiri, or pg), you should consider using a VPS with full root access instead, where you can install build tools as needed.
Can I run background jobs with Sidekiq or Resque on shared hosting?
Running background jobs on shared hosting is limited. You can set up cron jobs to run Rake tasks periodically, but real-time job processing with Sidekiq or Resque requires a message broker like Redis, which shared hosting typically does not provide. For production applications requiring background processing and real-time workers, a VPS is more suitable and more cost-effective than attempting complex workarounds.
What databases work with Rails on shared hosting?
MySQL and PostgreSQL both work with Rails through their respective gems (mysql2 and pg). AsiaGB shared hosting includes MySQL by default and supports it fully. The main concern is whether the mysql2 gem can compile successfully on the server, which may fail if native extension tools are not available. PostgreSQL requires a separate PostgreSQL server, which some shared hosting plans do not offer.
How do I check what Ruby version is available on the server?
After connecting via SSH, run the command ruby -v to see the installed Ruby version. You can also list available versions with ls ~/.rbenv/versions if rbenv is installed, or rvm list if RVM is installed. If no suitable Ruby version is available for your Rails application, contact the hosting provider to inquire about version upgrades or alternative arrangements.
Why is VPS better than shared hosting for Rails applications?
VPS provides full root access, allowing you to install any Ruby version, app server, background job processor, and system libraries your Rails application needs. AsiaGB VPS starts at just 500 baht per month and includes automatic backups twice monthly and 99% uptime guarantee, making it a practical choice for production Rails applications that outgrow shared hosting limitations. The flexibility and control justify the minimal additional cost for serious projects.
Ready for Production-Grade Rails Hosting?
AsiaGB VPS Linux starts at 500 baht per month and provides complete control for Ruby on Rails applications with automatic backups, 99% uptime, and locations in Thailand or Singapore.
View VPS Plans