Ruby on Rails is an open-source web development framework that is optimized for programmer productivity and rapid development. If you are not already familiar with it, check out its website at http://www.rubyonrails.org/ .
Virtualmin includes support for setting up Ruby on Rails in a virtual server, either to run applications developed in Ruby by the server's owner, or for running freely available application like Blogs and Wikis. Because Rails is typically run using a separate server process the setup can be quite complex, but almost all of it is automated by Virtualmin.
These instructions related to Virtualmin versions 3.48 and above. If you have an older version, we recommend upgrading first before continuing.
Most web applications are written in PHP or Perl, which are run either within the Apache webserver process, or as CGI scripts started by Apache. Ruby on Rails apps instead almost always use a separate webserver called Mongrel, which must run on a different TCP port. In order to make the application visible as part of a virtual server's website running on the standard web port 80, Apache must be configured to forward requests to the Mongrel webserver. Fortunately, Virtualmin can take care of this for you.
Because there is a limit on the number of concurrent requests a single Mongrel can handle, for high-load applications the solution is often to run multiple instances of Mongrel, and balance requests to a single URL path between them. As long as they all talk to the same database or files, there will be no problem of data consistency between the instances.
However, only Apache versions 2.2 and above with the
mod_proxy_balancer module support this configuration. But if you do have that Apache version and module installed, Virtualmin can setup the Mongrel instances and web server configuration for you automatically.
Because installing Rails applications involves the installation of Ruby packages (called Gems) containing database drivers and libraries, several dependencies must be installed on your system before using it. Many Gems compile code that links against libraries like MySQL, SQLite and glibc, which requires that a C compiler and headers for those libraries be installed. This section explains the steps you need to take on CentOS and Debian-based systems.
To install required packages on CentOS (and Fedora Linux), the command to run is :
yum install ruby ruby-devel gcc make mysql-devel sqlite sqlite-devel
Assuming that your YUM repository is set up correctly, this will download and install all needed packages that are not already on the system.
On Debian and Ubuntu systems, the command to install dependencies is :
apt-get install ruby1.8 ruby1.8-dev gcc make rake libc6-dev libmysqlclient15-dev libsqlite3-0
Because Debian-based systems do not have all required Apache modules enabled by default, you need to enable them by following these steps :
Login to Virtualmin, and select Webmin on the left menu.
Open the Servers category and click on the Apache Webserver module.
Click on the Global configuration tab, then on the Configure Apache Modules icon.
proxy_httpare selected, and click Save. If your system doesn't include the
proxy_balancermodule, don't worry.
Ruby on Rails applications are installed in Virtualmin using the Script Installers page, just as you would install PHP-based applications such as WordPress and SugarCRM. As with other scripts, they require a virtual server with a website and in most cases a MySQL database.
To install the Rails framework so that you can develop your own applications in Ruby, follow these steps :
Select the domain on Virtualmin's left menu, then click on Install Scripts.
In the Available scripts tab, select Ruby on Rails, then scroll down to the bottom and click Show Install Options.
If your entire website should be served by Rails, change the Install sub-directory option to At top level. Otherwise, leave it set to the second option, and change the sub-directory path as you wish.
If you want your Rails applications to use a database (highly recommended), select it from the Configure Rails to use database menu.
To run the initial Rails servers in development mode, change Use development mode? to Yes. This mode runs the applications slower, but makes it easier to make changes and debug problems.
If Apache on your system supports proxy balancing, the Number of Rails server processes field can be used to increase the number of Mongrel instances to run by default. One is enough for a basic application, but you may need five or more for one that is taking heavier load.
Finally, click Install Now.
If this is the first install of Rails on this system, the install process may take several minutes due to the need to download, compile and install several Ruby libraries. If anything goes wrong, an error message from the Ruby program that triggered it will be displayed - most are due to missing dependencies, so check the list above to make sure they are all installed.
Assuming all goes well, you will now be able to access Rails via the URL path you selected at install time (which will also be displayed by Virtualmin). Actual development of your own Ruby application that uses this environment is beyond the scope of this documentation.
Virtualmin also includes installers for several other Blogging, Wiki and CMS applications based on Ruby on Rails. The procedure for adding these is identical to other scripts, with the exception of the Number of Rails server processes field on the installation form, on systems where Apache supports it.
Some Rails applications are installed by download and extracting a source file (as is the case with most PHP scripts), while others are done using Ruby's Gems system, which can perform the required downloads itself.
For all Rails scripts, Virtualmin will setup an Apache proxy that forwards requests from the domain's website to the Mongrel server(s) that actually run the application. You can see this proxy in the Proxy Paths page - but don't delete or change it though, as doing so will stop the script from working.
All Ruby on Rails scripts installed by Virtualmin can be removed or upgraded in the same way as other scripts. Deleting a Rails application will also stop its Mongrel server processes and remove the Apache proxy configuration.
You can also stop, start and restart the Mongrel processes for a Ruby script from within Virtualmin. This can be done by going to the Script Installers page, clicking on the script name, and using the buttons at the bottom of the form (which also shows the status of the servers and the port(s) they use). When developing your own Rails applications, it may be necessary to restart the Mongrel servers to pick up changes you have made to the code, which can be done easily with the Restart Rails Server button.