BitNami Ruby Stack

    BitNami Ruby Stack greatly simplify the development and deployment of Ruby on Rails and its runtime dependencies. It includes ready-to-run versions of Ruby, Rails, MySQL, Git, Subversion, RVM and other components.

    How do I download and install Ruby Stack?

    rubystack-stack-icon.pngYou can download BitNami Ruby Stack for your platform at http://bitnami.com/stack/ruby There are installers available for Windows, OS X and Linux operating systems. Currently there are available three different versions of Ruby Stack:

    - 1.8.7: This version install latest version of Ruby 1.8.x and Rails 2.3.x

    - 1.9.3: This version ship latest version of Ruby 1.9.x and Rails 3.2.x

    2.0.0: This version ship latest version of Ruby 2.0.x and Rails 4.0.x

     

    These Stacks also include RVM and it is possible to install any Ruby version on top of any of these Stacks. Check the RVM guide to know how to install it.

     

    BitNami Ruby Stack can also be deployed as virtual machines. If you are using the virtual machine, please see our Virtual Appliances documentation for instructions on logging into the machine.

    The Stacks can be also deployed as AMIs in the Amazon cloud. Please take a look at our Amazon Cloud Images quick guide to see how to connect to the instance from your machine.

    BitNami Ruby Stack is distributed free of charge under the Apache 2.0 license.

    Which components are installed with 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 in 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
    • APC module
    • GD library
    • OpenSSL library
    • CURL library
    • OpenLDAP library
    • PEAR and PECL package manager tools

    What is the default installation directory?

    When using native installers the default installation directory depends on the platform and can be changed during the installation:

    win_platform.png On Windows: C:\BitNami\rubystack-VERSION (On previous versions, the default installation directory was C:\Program Files\BitNami Ruby Stack)

    mac_platform.png On OS X: /Applications/rubystack-VERSION

    linux_platform.png On Linux: /home/user/rubystack-VERSION

    If you are using a virtual machine or the AMI, the default installation directory is "/opt/bitnami".

    How do I start and stop the servers?

    Each Ruby Stack ships several servers that must be started before you will be able to work with them. By default, MySQL database and Apache servers are started after the installation.

    Graphical tool

    The Stacks include a graphical tool to manage the servers easily. You can find the "manager-windows.exe", "manager-osx" or "manager-linux" tool in your installation directory. Using this tool, you can Start, Stop or Restart the servers and check the log files. You can click on the icon to start it.

    manager-servers.png

     

    manager-osx.png

     

     

     

     

     

     

     

     

     


    win_platform.png

    On Windows: You can also start the Manager tool from shortcuts: Start -> Program Files -> BitNami Stack -> Manager tool

    Command line tool

    If you prefer, you can use the "ctlscript.sh" utility from the command line. This script is in the installation directory.

    linux_platform.png

    On Virtual Machines and Cloud images:

    $ sudo /opt/bitnami/ctlscript.sh start

    A native installer on Linux:

    $ cd ~/application-version
    $ ./ctlscript.sh start
    

    mac_platform.png

     

    On OS X: You can start the Manager tool from the installation directory or you can use the "ctlscript.sh" utility from a Terminal.

    host:~ user$ cd /Applications/application-version
    host:~ user$ ./ctlscript.sh start

    How can I run a command in the Ruby Stack?

    All of the Native Installers for BitNami Stacks are completely self-contained and run independently of the rest of the software or libraries installed on your system. To work correctly, certain environment variables need to be set when you want to invoke commands to access different binaries. Note that in virtual machines or AMIs, the environment is already loaded for the "bitnami" user automatically and the below is not necessary.

    To use RVM is necessary to access to the rubyconsole even if you are in an AMI or a virtual machine.

    BitNami console is a script to load the Stack environment. This console is useful to run any command included in the Stack: mysql, php, openssl, ruby, rake among others.

    linux_platform.png On Linux:

    $ cd ~/rubystack-version
    $ ./rubyconsole
    
    

    win_platform.png On Windows:

    There is a shortcut in Start -> BitNami Ruby Stack ->"Use Ruby Stack"

    You can also start the "use_ruby.bat" script that you can find in your installation directory.

    mac_platform.png On OS X:

    Open a Terminal and type the following:

    hostname:~ user$ cd /Applications/rubystack-version
    hostname:~ user$ ./rubyconsole
    

     

    It is important to know that you can have your own Ruby installation in your computer. If you run any Ruby command out of the rubyconsole, you will use the standard Ruby installed on your system. If you run the same command into the Rubyconsole you will use the Ruby files that is included in Ruby Stack. For example:

    This command will install rails gems in your Ruby installation. If you run this command out of the rubyconsole, this gem will be installed in the Ruby installed in your system.

    $ gem install rails
    

    If you run the same command into the Rubyconsole, the Rails gem will be installed in the Ruby that ships Ruby Stack. Everything will be self-contained and independent of the rest of the software installed on your system.

    How to install gems in your Ruby Stack?

    If you want to install any gem in your Ruby Stack, you only have to run the "gem install" command. Note that you have to run this command in the Ruby console.

    If you are installing a gem that requires to be compiled, you should have already installed the compilation tools: make, g++ and other tools.

    linux_platform.png On Linux: If you are using Ubuntu, you can install the "build-essential" package via "apt":

    sudo apt-get install build-essential
    

    If you are using other distro you can install g++ and make packages separately.

    win_platform.png On Windows: Bitnami Ruby Stack already ships a Development Kit. It is a MSYS/MinGW based toolkit than enables you to build many of the native C/C++ extensions available for Ruby.

    mac_platform.png On OS X: On OS X there are multiple ways of setup the required environment in OS X:

    * Install Xcode 4.1: This is the preferred way. There is no problems with using this version with the compilation of Rubies and the native gems.

    * Using  osx-gcc-installer, from Kenneth Reitz: This 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, which are found in the main Xcode install (because of license restrictions from Apple). This means that some native gems will fail to compile. You could still get the header packs from Apple but you will have to be a registered Apple Developer.

    * Using Xcode 4.2+: These versions of Xcode use a non-compatible version of GCC. If you want to use them, you will need to start installing Xcode 4.1, and then upgrade, answering not to them when asked to remove prior versions. Then you will have to use '/usr/bin/gcc-4.2' to compile.

     

    How to start with the sample Rails project?

    Once the installation or deployment finishes, you can access the welcome page from your browser. If you have installed the stack on a local machine as a regular user, you can access it at http://localhost on Windows or http://localhost:8080 on OS X and Linux. If not, you can specify the IP address of the server where you installed the Stack. This sample project is optional, if you did not select during the installation, you can check "How to create your own Rails project" section.

    You should see something similar to this page:

    rubystack-welcome.png

     

    Open the Ruby Stack console and go to the "projects" folder:

    $ cd projects/sample
    

    Then start the Rails server with the sample application:

    $ ruby script/rails server
    

    If you are using a previous version (Rails 2.x instead of Rails 3x), the command that you should execute is the
    following:

    $ ruby script/server
    

    You can see something like this:

      => Booting WEBrick
      => Rails 3.2.8 application starting on http://0.0.0.0:3000
      => Call with -d to detach
      => Ctrl-C to shutdown server
      [     ] INFO  WEBrick 1.3.1
      [     ] INFO  ruby 1.9.3 (2012-06-08) [i686-linux]
      [     ] INFO  WEBrick::HTTPServer#start: pid=3061 port=3000
    

    Then try to access at http://localhost:3000 from your browser.

    How to start with your own Rails project?

    Ruby Stack creates a "project" folder into the installation directory. We suggest to copy your project to this folder to have everything you need into the installation directory. This folder will not be removed during the uninstallation.

    1. Copy your project to the "project" folder in your installation directory.
    2. Open the Ruby Stack console
    3. Start using your Rails project running any command: rake, rails, mysql, etc.

    If you want that Rubyconsole open your project directly, you can edit the "rubyconsole" file and add the following:

    cd your_installdir/projects/your_rails_application
    

    Once you open the rubyconsole you will start in your own project directory.

    How to create your own Rails project?

    Open the Ruby Stack console and run the "rails" command followed by the name of your desired application inside the Rails Environment:

    $ rails new my_new_app
    

    It is possible that you can see the following error on Linux:

    Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs 
    for a list of available runtimes. (ExecJS::RuntimeUnavailable)
    

    In this case you only have to add the rubyracer gem that is already included in Ruby Stack into the "Gemfile":

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

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

    Open a Ruby Stack console and connect to the mysql database:

    $ mysql -u root 
    

    From there you can run the following:

    mysql> CREATE DATABASE IF NOT EXISTS my_new_app_production;
    mysql> CREATE DATABASE IF NOT EXISTS my_new_app_development;
    mysql> CREATE DATABASE IF NOT EXISTS my_new_app_test;
    mysql> GRANT ALL PRIVILEGES on my_new_app_test.* to 'rubystack'@'localhost' identified by 'your_password';
    mysql> GRANT ALL PRIVILEGES on my_new_app_production.* to 'rubystack'@'localhost';
    mysql> GRANT ALL PRIVILEGES on my_new_app_development.* to 'rubystack'@'localhost'; flush privileges;
    

    Then it is necessary to configure your Rails application to connect to the database. Edit the 'config/database.yml' file and specify the following configuration. You can also copy the 'database.yml' file from the sample project and modify the database name according to your database:

    development:
      adapter: mysql2
      database: my_new_app_development
      username: rubystack
      password: your_password
      host: localhost
      socket: /your_install_dir/mysql/tmp/mysql.sock
      #port: 3306
    test:
      adapter: mysql2
      database: my_new_app_test
      username: rubystack
      password: your_password
      socket: /your_install_dir/mysql/tmp/mysql.sock
      #port: 3306
    production:
      adapter: mysql2
      database: my_new_app_production
      username: rubystack
      password: your_password
      socket: /your_install_dir/mysql/tmp/mysql.sock
      #port: 3306
    

    Note that this configuration is for Linux and OS X. On Windows it is necessary to specify the port instead of the socket path.

    How can I add applications on top of Ruby Stack?

    BitNami Native Installers come in two formats: stand-alone Stacks and Modules. If you only want to install one BitNami-packaged application, then just download and install the Stack. It will contain everything you need to run the application.

    If you want to run more than one application, you can install several application Modules on top of it. That way, all of the BitNami-packaged applications you want to run will share a single instance of Apache, MySQL and PHP, which will save space and improve performance.

    nuevo_php_stacks.jpg 

    You can download and install any PHP-based and Ruby-based BitNami applications (For example: WordPress, Joomla!, Redmine, SugarCRM...) on top of an existing BitNami Ruby Stack deployment. You can do so by downloading and installing a module. You can download the available modules for Ruby Stack at http://bitnami.com/stack/ruby/modules

    IMPORTANT: PHP is optional for Ruby Stack. If you want to install any PHP-based applications on top of Ruby Stack you should enable PHP during the installation.

    Once you have downloaded the module, click on it to start the installation process. During the installation process, you will need to specify the  installation directory of your installed Ruby Stack. If you are using the virtual machine or AMI, the default installation directory is "/opt/bitnami".

    module-installdir.png

    You will also need to specify the MySQL root password. This password is the same as the one that you specified in your Ruby Stack installation. If you are using the virtual machine or AMIs, the default password is "bitnami".

    module-password.png

    After the installation process is complete, you can access the installed application from your browser. For example, if you have installed WordPress, you can access it at http://localhost/wordpress on Windows or http://localhost:8080/wordpress on OS X or Linux. Substitute localhost for the right IP address or domain name if you are using a virtual machine or cloud server. The username and password is specified during the installation of the module. You will see something similar to:

    module-link.png

    If you are using a BitNami Ruby Stack in a machine without a graphical interface, you can run the module installer in text mode. You can use the following command to download and install any BitNami module from the command line:

    $ wget http://bitnami.com/... (Link to the module)
    $ chmod 755 bitnami-*
    $ ./bitnami-*
    

    How can I deploy my Rails application?

    There are different ways to deploy a Rails application:

    Using Apache with Thin

    This approach consists on having multiple Thin processes running in different ports. Once they are running, Apache will be set up as a proxy balancer, sending the Rails requests to those ports. It is based in Thin parser, Event Machine and Rack.

    On Linux and OS X, you can store the configuration in a yml file and use it to start an  stop the group easily. For example:

    $ cd your_project_folder
    $ thin -s 5 -p 3000 -e production --prefix /appname -C config/thin.yml config
    

    Which will configure 5 processes in ports 3000 to 3004, running in a production environment and using prefix /appname. Once the configuration file has been generated, you can start, stop or restart the by running:

    $ thin -C ${rails_application_dir}/config/thin.yml start/stop/restart
    

    If you are using Ruby Stack on Windows, you can't start multiple servers using "-s" option. You will need to call a command for each instance:

    $ cd your_project_folder
    $ thin -p 3000 -e production --prefix /appname start thin -p 3001 -e production --prefix /appname start
    

    Regarding Apache, you may include the following lines to apache2/conf/httpd.conf:

    ProxyPass /appname balancer://appcluster
    ProxyPassReverse /appname balancer://appcluster
    <Proxy balancer://appcluster>
       BalancerMember http://127.0.0.1:3001/appname
       BalancerMember http://127.0.0.1:3002/appname
       ...
    </Proxy>
    

    That way, each time a Rails request is received it will be sent to the thin servers running in ports 3001, 3002, etc. After restarting Apache the application should be accessible at http://domain:port/appname.

    Using Apache with Passenger

    Passenger is only available for OS X and Linux. To use this method, you just need to include a virtual host which DocumentRoot points to 'public' directory in Rails application.

    <VirtualHost *:80>
        ServerName myapplication.com
        DocumentRoot your_project_folder/public
        <Directory your_project_folder/public>
            Options -MultiViews
            <IfVersion < 2.3 >
            Order allow,deny
            Allow from all
            </IfVersion>
            <IfVersion >= 2.3>
            Require all granted
            </IfVersion>
        </Directory>
    </VirtualHost>
    

    You should make sure that the 'public' and 'config' application folders and their parent directories are readable and executable by Apache. After restarting Apache you can access to your application. It is also possible to deploy a set of applications to different sub URIs. In order to do so, create a root directory which contains links to each of the application's public paths. For example, you can do something like:

    $ mkdir your_installdir/webapps
    $ ln -s your_installdir/app/railsapp1/public your_installdir/webapps/railsapp1
    $ ln -s your_installdir/app/railsapp2/public your_installdir/webapps/railsapp2
    

    Once the links are created, configure Apache using a RailsBaseURI entry for each application to be deployed:

    <VirtualHost *:80>
        ServerName myapplication.com
        DocumentRoot ${installdir}/webapps
        <Directory ${installdir}/webapps>
            Options -MultiViews
            <IfVersion < 2.3 >
            Order allow,deny
            Allow from all
            </IfVersion>
            <IfVersion >= 2.3>
            Require all granted
            </IfVersion>
        </Directory>
        RailsBaseURI /railsapp1
        RailsBaseURI /railsapp2
    </VirtualHost>
    

    After restarting Apache, the applications will be accessible at:

    http://localhost/railsapp1/ and http://localhost/railsapp2/

    How can I access phpMyAdmin?

    phpMyAdmin and phpPgAdmin are popular web-based management tools for the MySQL and PostgreSQL databases.

    phpMyAdmin and phpPgAdmin

    Tag page (Edit tags)
    • No tags
    Pages that link here
    Page statistics
    147273 view(s), 35 edit(s) and 24523 character(s)

    Comments

    You must login to post a comment.

    Attach file

    Attachments