Bitnami Ruby Installer

NOTE: Before running the commands shown on this page, you should load the Bitnami stack environment by executing the installdir/use_APPNAME script (Linux and Mac OS X) or by clicking the shortcut in the Start Menu under "Start -> Bitnami APPNAME Stack -> Application console" (Windows). Learn more.
NOTE: When running the commands shown on this page, replace the installdir placeholder with the full installation directory for your Bitnami stack.

Description

Ruby on Rails is a full-stack development environment optimized for programmer happiness and sustainable productivity. It lets you write beautiful code by favoring convention over configuration.

First steps with the Bitnami Ruby Stack

Welcome to your new Bitnami application! Here are a few questions (and answers!) you might need when first starting with your application.

What are the system requirements?

Before you download and install your application, check that your system meets these requirements.

How do I install the Bitnami Ruby Stack?

Windows, OS X and Linux installer
  • Download the executable file for the Bitnami Ruby Stack from the Bitnami website.

  • Run the downloaded file:

    • On Linux, give the installer executable permissions and run the installation file in the console.
    • On other platforms, double-click the installer and follow the instructions shown.

Check the FAQ for instructions on how to download and install a Bitnami Stack for more details.

The application will be installed to the following default directories:

Operating System Directory
Windows C:\Bitnami\APPNAME-VERSION
Mac OS X /Applications/APPNAME-VERSION
Linux /opt/APPNAME-VERSION (running as root user)
OS X VM
  • Download the OS X VM file for the Bitnami Ruby Stack from the Bitnami website.
  • Begin the installation process by double-clicking the image file and dragging the WordPress OS X VM icon to the Applications folder.
  • Launch the VM by double-clicking the icon in the Applications folder.

What credentials do I need?

You need application credentials, consisting of a password. This will allow you to log in to the services of the Bitnami stack.

What is the administrator password?

  • For Windows, Linux and OS X installers, the password was configured by you when you first installed the application.
  • For OS X VMs, the password can be obtained by clicking the Bitnami badge at the bottom right corner of the application welcome page.

How to start or stop the services?

Linux

Bitnami native installers include a graphical tool to manage services. This tool is named manager-linux-x64.run on Linux and is located in the installation directory. To use this tool, double-click the file and then use the graphical interface to start, stop or restart services. Server log messages can be checked in the "Server Events" tab.

Management tool

The native installer also includes a command-line script to start, stop and restart applications, named ctlscript.sh. This script can be found in the installation directory and accepts the options start, stop, restart, and status. To use it, log in to the server console and execute it following the examples below:

  • Call it without any service names to start all services:

      $ sudo installdir/ctlscript.sh start
    
  • Use it to restart a specific service only by passing the service name as argument - for example, mysql, postgresql or apache:

      $ sudo installdir/ctlscript.sh restart mysql
      $ sudo installdir/ctlscript.sh restart postgresql
      $ sudo installdir/ctlscript.sh restart apache
    
  • Obtain current status of all services:

      $ installdir/ctlscript.sh status
    

The list of available services varies depending on the required components for each application.

Mac OS X

Bitnami native installers include a graphical tool to manage services. This tool is named manager-osx on Mac OS X and is located in the installation directory. To use this tool, double-click the file and then use the graphical interface to start, stop or restart services. Server log messages can be checked in the "Server Events" tab.

Management tool

The native installer also includes a command-line script to start, stop and restart applications, named ctlscript.sh. This script can be found in the installation directory and accepts the options start, stop, restart, and status. To use it, log in to the server console and execute it following the examples below:

  • Call it without any service names to start all services:

    $ sudo installdir/ctlscript.sh start
    
  • Use it to restart a specific service only by passing the service name as argument - for example, mysql or apache:

     $ sudo installdir/ctlscript.sh restart mysql
     $ sudo installdir/ctlscript.sh restart apache
    
  • Obtain current status of all services:

     $ installdir/ctlscript.sh status
    

The list of available services varies depending on the required components for each application.

NOTE: If you are using the stack manager for Mac OS X-VM, please check the following blog post to learn how to manage services from its graphical tool.

Windows

Bitnami native installers include a graphical tool to manage services. This tool is named manager-windows.exe on Windows and is located in the installation directory. To use this tool, double-click the file and then use the graphical interface to start, stop or restart services. Server log messages can be checked in the "Server Events" tab.

Management tool

The Windows native installer creates shortcuts to start and stop services created in the Start Menu, under "Programs -> Bitnami APPNAME Stack -> Bitnami Service". Servers can also be managed from the Windows "Services" control panel. Services are named using the format APPNAMESERVICENAME, where APPNAME is a placeholder for the application name and SERVICENAME is a placeholder for the service name. For example, the native installer for the Bitnami WordPress Stack installs services named wordpressApache and wordpressMySQL.

These services will be automatically started during boot. To modify this behaviour, refer to the section on disabling services on Windows.

Which components are installed with the Bitnami Ruby Stack?

The Bitnami Ruby Stack ships the components listed below. If you want to know which specific version of each component is bundled in the stack you are downloading, check the README.txt file on the download page or in the stack installation directory. You can also find more information about each component using the links below.

Main components

Dependencies and additional components

  • Varnish proxy cache server
  • ImageMagick tool
  • SQLite database
  • ModSecurity module
  • XDebug module
  • Xcache module
  • OAuth module
  • Memcache module
  • FastCGI module
  • GD library
  • OpenSSL library
  • CURL library
  • OpenLDAP library
  • PEAR and PECL package manager tools

How to find a specific component?

Find the different components of the stack in these directories. Note that some components may not be available on all platforms.

  • installdir/mysql/: MySQL Database.
  • installdir/ruby/: Ruby, Ruby gems, Rails
  • installdir/git/: Distributed version control system
  • installdir/sqlite/: SQLite database server
  • installdir/apache2/: Apache Web server
  • installdir/memcached/: Distributed memory object caching system
  • installdir/nginx/: NGinx Web server
  • installdir/sphinx/: Sphinx search engine
  • installdir/perl/: Perl scripting language
  • installdir/varnish/: Varnish cache server
  • installdir/licenses/: License files
  • installdir/php/: PHP
  • installdir/apps/phpmyadmin: Management tool for MySQL

How can I get started with Ruby?

To get started, we suggest the following steps:

Step 1. Create a new Rails application.

To create a new Rails application, initialize a new project as below. Remember to replace the APPNAME placeholder with the actual name of your project.

$ rails new APPNAME

For more information, refer to these instructions.

Step 2. Install gems.

You might need to install gems for your project. You can do this easily with the gem install command. For example, run the following command to install Rake:

$ sudo gem install rake

For more information, refer to these instructions.

Step 3. Deploy your Rails application.

To deploy your application, start the Rails server by running the following command:

$ bundle exec rails s

This will start the Rails server for your application on port 3000. Find more information about how to access the application using your Web browser.

For a production environment, we recommend configuring Apache or Nginx with Passenger before starting to serve your application. For more information, refer to these instructions.

How to access a Ruby server application?

Access the application by browsing to http://localhost:3000/. Depending on how your system is configured, it may be necessary to first open that port in the server firewall.

How to find the MySQL database credentials?

How to find the database credentials?

  • Database username: postgres.
  • Database password: The password entered during the installation process.

How to connect to the MySQL database?

You can connect to the MySQL database from the same computer where it is installed with the mysql client tool.

$ mysql -u root -p

You will be prompted to enter the root user password. This is the same as the application password.

How to connect to the PostgreSQL database?

You can connect to the PostgreSQL database from the same computer where it is installed with the psql client tool.

$ psql -U postgres

You will be prompted to enter the *postgres* user password. This is the same as the [application password](/installer/faq#how-to-find-application-credentials).

How to access phpMyAdmin?

You should be able to access phpMyAdmin directly, by browsing to http://127.0.0.1/phpmyadmin.

The username is root for phpMyAdmin, and the password is the one specified by you during the installation process.

How to access phpPgAdmin?

You should be able to access phpPgAdmin directly, by browsing to http://127.0.0.1:8080/phppgadmin (Linux or Mac OS X) or http://127.0.0.1/phppgadmin (Windows).

The username is postgres for phpPgAdmin, and the password is the one specified by you during the installation process.

How to reset the MariaDB root password?

Please note that depending on the version you have installed, you may find the MariaDB files at installdir/mysql

If you don't remember your MariaDB root password, you can follow the steps below to reset it to a new value:

  • Create a file in /home/bitnami/mysql-init with the content shown below (replace NEW_PASSWORD with the password you wish to use):

     UPDATE mysql.user SET Password=PASSWORD('NEW_PASSWORD') WHERE User='root';
     FLUSH PRIVILEGES;
    
  • Stop the MariaDB server:

     $ sudo installdir/ctlscript.sh stop mariadb
    
  • Start MariaDB with the following command:

     $ sudo installdir/mariadb/bin/mysqld_safe --defaults-file=installdir/mariadb/my.cnf --pid-file=installdir/mariadb/data/mysqld.pid --init-file=/home/bitnami/mysql-init 2> /dev/null &
    
  • Restart the MariaDB server:

     $ sudo installdir/ctlscript.sh restart mariadb
    
  • Remove the init script

     $ rm /home/bitnami/mysql-init
    

How to change the MariaDB root password?

You can modify the MariaDB password using the following command at the shell prompt:

$ installdir/mariadb/bin/mysqladmin -p -u root password NEW_PASSWORD

How can I run a command in the Bitnami Ruby Stack?

The Bitnami Console is a script to load the Bitnami stack environment. This console is useful to run any command included in the stack, including mysql, php, openssl, ruby, rake and others.

To run this script, execute the command below.

Linux and Mac OS X

At the console:

$ cd installdir
$ ./rubyconsole

Windows

Use the shortcut in the Start menu under "Start -> Bitnami Ruby Stack -> Use Ruby".

Once the Ruby console has loaded, execute a Ruby command as you normally would. For example, this command executes a simple Ruby program:

$ ruby -e 'print 1+1'

You can also use other commands, including rvm, as shown below:

$ rvm info
IMPORTANT: The Bitnami Ruby Stack can co-exist nicely with other existing Ruby installations on your system. Running a Ruby command through the Bitnami console will use the components/files that are part of the Bitnami Ruby Stack. Running a Ruby command outside the Bitnami console will use your existing Ruby installation. To illustrate, if you run the command gem install rails through the Bitnami console, it will install the Rails gems into the Bitnami Ruby Stack. However, if you run the same command outside the console, it will install the Rails gems into your other (non-Bitnami) Ruby environment.

How to start with the sample Rails project?

When using a native installer, the sample project is located in the installdir/projects/sample folder. Follow these steps:

  • Load the Bitnami console.

     $ cd installdir
     $ ./rubyconsole
    
  • Start the Rails server with the sample application.

     $ cd installdir/projects/sample
     $ ruby bin/rails server (for Rails 3.x)
     $ ruby bin/server (for Rails 2.x)
    

You should see something like this:

=> Booting WEBrick
=> Rails 4.2.2 application starting on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[     ] INFO  WEBrick 1.3.1
[     ] INFO  ruby 2.0.0 (2015-04-13) [x86_64-darwin10.0.0]
[     ] INFO  WEBrick::HTTPServer#start: pid=3061 port=3000

You should now be able to access the sample application

How to create a new Rails application?

To create a new Rails project, load the Bitnami console, change to the installdir directory and initialize a new project as below. Remember to replace the APPNAME placeholder with the actual name of your project.

$ cd installdir
$ ./rubyconsole
$ rails new APPNAME

Next, start the Rails server by running the following command:

$ cd installdir/APPNAME
$ bundle exec rails s

This will start the Rails server for your application on port 3000. Find more information about how to access the application using your Web browser.

If you see an error on Linux stating "Could not find a JavaScript runtime", you must add the rubyracer gem (already included in the Bitnami Ruby Stack) into the Gemfile, as below:

...
gem 'sqlite3'
gem 'therubyracer'
...

How to deploy a new Rails application?

There are different ways to deploy a Rails application.

Using Apache with Passenger

The most common way to deploy a Rails application is with Apache and Passenger. Follow the steps below:

  • Create a new file at installdir/httpd-vhosts.conf and fill it with the following content.

    <VirtualHost *:80>
       ServerName HOST_NAME
       DocumentRoot "installdir/APPNAME/public/"
        <Directory "installdir/APPNAME/public/">
            Options -MultiViews
            <IfVersion < 2.3 >
            Order allow,deny
            Allow from all
            </IfVersion>
            <IfVersion >= 2.3>
            Require all granted
            </IfVersion>
            RailsEnv development
            PassengerEnabled on
            PassengerAppRoot "installdir/APPNAME/"
        </Directory>
    </VirtualHost>
    

    Remember to replace the HOST_NAME placeholder with the host name of your cloud server and the APPNAME placeholter with the correct directory for your Rails application.

  • Next, edit the installdir/apache2/conf/bitnami/bitnami-apps-vhosts.conf file and add the following line to the end of the file:

     Include installdir/httpd-vhosts.conf
    
  • Restart the Apache server.

     $ sudo installdir/ctlscript.sh restart apache
    

After restarting Apache, the application should be accessible by browsing to http://localhost.

NOTE: Remember that you might need to adjust the permissions of your application directory and sub-directories to make them accessible to the user that the Apache server runs as - for example, with the command sudo chown bitnami:daemon installdir/APPNAME.

Using Nginx with Passenger

Follow these steps:

  • To configure Nginx to run at port 80, stop the Apache service. To do this, run the command below:

     $ sudo installdir/ctlscript.sh stop apache
    
  • Once the Apache service has been stopped, modify the server configuration at installdir/nginx/conf/nginx.conf to be similar to this.

     server {
         listen 80;
         root installdir/APPNAME/public;
         passenger_enabled on;
         rails_env development;
     }
    
    NOTE: The configuration above runs Passenger in development mode because, by default, Passenger starts in production mode which requires a secret to be configured. Using development mode bypasses this requirement and lets you test that everything is working correctly. When deploying to production, remember to change this value and provide a secret.
  • Before restarting Nginx to apply this configuration, disable Apache as shown below:

     $ sudo installdir/ctlscript.sh stop apache
     $ sudo mv installdir/apache2/scripts/ctl.sh installdir/apache2/scripts/ctl.sh.disabled
     $ sudo mv installdir/config/monit/conf.d/apache.conf installdir/config/monit/apache.conf.disabled
    
  • Restart the Nginx service to apply the new configuration:

     $ sudo installdir/ctlscript.sh restart nginx
    

With this, your Ruby on Rails application will run at the root of your domain through the default HTTP port (80). You should now be able to access your Ruby on Rails applications with Nginx and Passenger on http://localhost/.

How to create a new MySQL database for a Rails application?

To create a new MySQL database for a Rails application:

  • Start the MySQL command line client, as shown below. Enter the password for the MySQL root user.

     $ mysql -u root -p
    
  • At the MySQL prompt, run the following commands. Remember to replace the DBNAME, APPNAME and PASSWORD placeholders with actual values for your database name, application name and database user password.

     mysql> CREATE DATABASE IF NOT EXISTS DBNAME_production;
     mysql> CREATE DATABASE IF NOT EXISTS DBNAME_development;
     mysql> CREATE DATABASE IF NOT EXISTS DBNAME_test;
     mysql> GRANT ALL PRIVILEGES on DBNAME_test.* to 'APPNAME'@'localhost' identified by 'PASSWORD';
     mysql> GRANT ALL PRIVILEGES on DBNAME_production.* to 'APPNAME'@'localhost';
     mysql> GRANT ALL PRIVILEGES on DBNAME_development.* to 'APPNAME'@'localhost';
     mysql> FLUSH PRIVILEGES;
    
  • Edit the config/database.yml file in your Rails project directory and update the database configuration. You can also copy the database.yml file from a sample or fresh project and modify the database details as needed:

     development:
       adapter: jdbc
       driver: com.mysql.jdbc.Driver
       url: jdbc:mysql://localhost:3306/DBNAME_development
       username: APPNAME
       password: PASSWORD
    
     test:
       adapter: jdbc
       driver: com.mysql.jdbc.Driver
       url: jdbc:mysql://localhost:3306/DBNAME_test
       username: APPNAME
       password: PASSWORD
    
     production:
       adapter: jdbc
       driver: com.mysql.jdbc.Driver
       url: jdbc:mysql://localhost:3306/DBNAME_production
       username: APPNAME
       password: PASSWORD
    

How to install gems in the Bitnami Ruby Stack?

If you want to install a gem in the Bitnami Ruby Stack, run the gem install command. Note that this command should be run only after loading the Bitnami console. For example, use this sequence of commands to install Rake:

$ ./rubyconsole
$ ruby -S gem install rake

If you are installing a gem that requires compilation, you will need compilation tools like make, g++ and others. On native installers, these compilation tools can be installed separately as discussed below.

Linux

If you are using Ubuntu, install the build-essential package via apt as shown below:

$ sudo apt-get install build-essential

If you are using a different Linux distribution, install g++ and build packages separately following the instructions provided by your distribution.

Windows

The Bitnami Ruby Stack already includes a Development Kit for Windows users. It is a MSYS/MinGW-based toolkit that enables you to build many of the native C/C++ extensions available for Ruby.

Mac OS X

On Mac OS X, either install Xcode 4.1 (preferred), use the osx-gcc-installer from Kenneth Reitz, or use Xcode 4.2+.

NOTE: The osx-gcc-installer is a stripped-down version of Xcode 4.1, which only includes GCC and the required libraries. The limitation of this solution is that it does not include certain headers (such as the Carbon/Cocoa headers found in the main Xcode installation) because of licensing restrictions. This means that some native gems will fail to compile. Registered Apple developers can get the necessary header packs from Apple.
NOTE: Xcode 4.2+ versions use a non-compatible version of GCC. To use these, first install Xcode 4.1 and then upgrade to your desired version, answering "no" when asked to remove prior versions. Once the upgrade is complete, compile using the binary at /usr/bin/gcc-4.2.

What versions are available of the Bitnami Ruby Stack?

Currently available versions include:

  • Ruby Stack v1.9.3: Includes the latest version of Ruby 1.9.x and Rails 3.2.x
  • Ruby Stack v2.0.0: Includes the latest version of Ruby 2.0.x and Rails 4.x
  • Ruby Stack v2.1.6: Includes the latest version of Ruby 2.1.x and Rails 4.x
  • Ruby Stack v2.2.2: Includes the latest version of Ruby 2.2.x and Rails 3.2.x

The Bitnami Ruby Stack also includes RVM and it is possible to install any Ruby version on top of the Bitnami Ruby Stack. Read more about RVM.

How to create a full backup of Ruby?

The Bitnami Ruby Stack is self-contained and the simplest option for performing a backup is to copy or compress the Bitnami stack installation directory. To do so in a safe manner, you will need to stop all servers, so this method may not be appropriate if you have people accessing the application continuously.

NOTE: If you want to create only a database backup, refer to these instructions for MySQL and PostgreSQL.

Backup on Linux and Mac OS X

Follow these steps:

  • Change to the directory in which you wish to save your backup.

     $ cd /your/directory
    
  • Stop all servers.

     $ sudo installdir/ctlscript.sh stop
    
  • Create a compressed file with the stack contents.

     $ sudo tar -pczvf application-backup.tar.gz installdir
    
  • Start all servers.

     $ sudo installdir/ctlscript.sh start
    
  • Download or transfer the application-backup.tar.gz file to a safe location.

You should now download or transfer the application-backup.tar.gz file to a safe location.

Backup on Windows

Follow these steps:

  • Stop all servers using the shortcuts in the Start Menu or the graphical manager tool.

  • Create a compressed file with the stack contents. You can use a graphical tool like 7-Zip or WinZip or just right-click the folder, click "Send to", and select the "Compressed (zipped) folder" option.

  • Download or transfer the compressed file to a safe location.

  • Start all servers using the shortcuts in the Start Menu or the graphical manager tool.

Restore on Linux and Mac OS X

Follow these steps:

  • Change to the directory containing your backup:

    $ cd /your/directory
    
  • Stop all servers.

    $ sudo installdir/ctlscript.sh stop
    
  • Move the current stack to a different location:

    $ sudo mv installdir /tmp/bitnami-backup
    
  • Uncompress the backup file to the original directory:

    $ sudo tar -pxzvf application-backup.tar.gz -C /
    
  • Start all servers.

    $ sudo installdir/ctlscript.sh start
    
IMPORTANT: When restoring, remember to maintain the original permissions for the files and folders. For example, if you originally installed the stack as the root user on Linux, make sure that the restored files are owned by root as well.

Restore on Windows

  • Change to the directory containing your backup:

       $ cd /your/directory
    
  • Stop all servers using the shortcuts in the Start Menu or the graphical manager tool.

  • Uninstall the previous services by executing the following command:

        $ serviceinstall.bat
    
  • Create a safe folder named Backups in the desktop and move the current stack to it. Remember to replace PATH with the right location of your folder:

        $ move installdir \PATH\Backups
    
  • Uncompress the backup file using a tool like 7-Zip or Winzip or just double-click the .zip file to uncompress it, and move it to the original directory.
  • Install services by running the following commands from an elevated command prompt:

      $ cd installdir
      $ serviceinstall.bat INSTALL
    
  • Start all servers using the shortcuts in the Start Menu or the graphical manager tool.

How to debug errors in your database?

The main log file is created at installdir/mysql/data/mysqld.log on the MySQL database server host.

nativeInstaller

Bitnami Documentation