Setting Up a Ruby App on cPanel with CloudLinux
Deploying a Ruby application on a server running cPanel with CloudLinux can be straightforward when following a well-structured approach. This guide walks through the steps of setting up and managing a Ruby app on cPanel, with a focus on ensuring compatibility, security, and optimal performance using CloudLinux.
Prerequisites:
- Access to a cPanel account on a server running CloudLinux.
- Ruby installed via CloudLinux’s CageFS.
- A Ruby application or framework, such as Ruby on Rails.
Step 1: Ensure Ruby Support is Enabled
Before starting, confirm that Ruby is supported on your server. With CloudLinux, you have the benefit of multiple versions of programming languages, including Ruby. You can check this by accessing the CloudLinux Selector in cPanel.
- Log into cPanel.
- Navigate to the Software section.
- Open Setup Ruby App (this is usually integrated into the CloudLinux tools on supported servers).
Here, you can see if Ruby is available and which versions you can select. If it’s not installed, contact your hosting provider to have Ruby enabled.
Step 2: Set Up the Ruby Application Environment
To deploy a Ruby app, you must first set up the environment. cPanel allows you to create and manage your Ruby environment using Setup Ruby App. Follow these steps:
- In Setup Ruby App, click on Create Application.
- Select the version of Ruby you want to use from the dropdown list. CloudLinux will offer several stable versions.
- Set the Application Root, which is the directory where your Ruby app will reside.
- Configure the App URL and App Type:
- The App URL defines the web address that will access your app (e.g.,
myapp.example.com
orexample.com/myapp
). - For App Type, select whether it’s a Rack or Ruby on Rails app, depending on your project.
- The App URL defines the web address that will access your app (e.g.,
- Click Create to finalize the setup. This creates the virtual environment for your app and installs Ruby.
Step 3: Upload Your Ruby Application
After setting up the environment, you need to upload your Ruby application files to the server.
- Upload via File Manager: In cPanel, go to the File Manager and navigate to the application root directory that you specified in the previous step. Use the File Manager interface to upload your application’s files.
- Upload via FTP: Alternatively, use an FTP client (like FileZilla) to transfer the files to the server.
After the files are uploaded, ensure that your application files are located in the correct directories. The app
directory, configuration files, and Gemfile
should all be in place.
Step 4: Install Required Ruby Gems
To run your Ruby application, you’ll need to install its dependencies. Most Ruby apps manage dependencies through Gemfile
, which lists the necessary Ruby gems.
- SSH Access: You’ll need SSH access to your cPanel account for this step.
- Once logged in via SSH, navigate to your application root:
cd ~/myapp
- Run the following command to install the required gems:
bundle install --deployment
This will install the gems listed in your Gemfile
into a vendor/bundle
directory.
Step 5: Configure the Web Server (Passenger)
Ruby apps often run behind a web server such as Phusion Passenger, which is commonly used for deploying Ruby apps on cPanel. Passenger automatically integrates with Apache when installed.
- In Setup Ruby App in cPanel, locate the app you created.
- You should see an option to Run Application. This will restart Passenger to serve your Ruby app.
- You may need to configure Apache or NGINX as a reverse proxy if the Ruby app isn’t accessible directly. For most cPanel environments with CloudLinux, this should be pre-configured by your host.
Step 6: Managing Resource Usage with CloudLinux
One of the key benefits of using CloudLinux is its resource management capabilities. CloudLinux uses LVE (Lightweight Virtualized Environment) to limit the amount of CPU, memory, and other resources a single cPanel account can consume. This prevents one user from impacting the performance of others.
- Go to the Resource Usage section in cPanel. Here, you can see the real-time usage of resources such as CPU, memory, and I/O.
- If your app frequently hits resource limits, you can either optimize your Ruby code or consider upgrading your hosting plan for additional resources.
Step 7: Testing and Troubleshooting
Finally, ensure your application is running correctly by visiting the App URL you configured in Step 2.
- If your application doesn’t start, check the Passenger logs located in
~/logs/
for errors. - Ensure all dependencies are installed and that there are no permission issues.
Additional Notes:
- Database Configuration: If your Ruby app requires a database, you can create and manage MySQL or PostgreSQL databases via cPanel’s MySQL Databases or PostgreSQL Databases sections.
- SSL: To secure your app with HTTPS, you can install an SSL certificate via the SSL/TLS section in cPanel or use AutoSSL for a free certificate.
Conclusion
Deploying a Ruby app on cPanel with CloudLinux is an efficient process thanks to the flexibility of CloudLinux’s multi-version support and resource management. Using cPanel’s intuitive interface, you can quickly configure, deploy, and manage your Ruby applications, ensuring they run smoothly and securely. CloudLinux’s resource isolation helps keep the server stable, even when running resource-intensive apps.
By following the steps outlined here, you should be able to successfully get your Ruby application up and running.