Deploy your Bitnami JRuby Stack on CenturyLink Cloud now! Launch Now

Description

JRuby is a 100% Java implementation of the Ruby programming language. It is Ruby for the JVM. JRuby provides a complete set of core built-in classes and syntax for the Ruby language.

First steps with the Bitnami JRuby Stack

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

What credentials do I need?

You need two sets of credentials:

  • The application password that allows you to log in to your new Bitnami application.
  • The server credentials that allow you to log in to your CenturyLink Cloud server using an SSH client and execute commands on the server using the command line. These credentials consist of an SSH username and key.

What SSH username should I use for secure shell access to my application?

SSH username: bitnami

How to start or stop the services?

Each Bitnami stack includes a control script that lets you easily stop, start and restart services. The script is located at /opt/bitnami/ctlscript.sh. Call it without any service name arguments to start all services:

$ sudo /opt/bitnami/ctlscript.sh start

Or use it to restart a single service, such as Apache only, by passing the service name as argument:

$ sudo /opt/bitnami/ctlscript.sh restart apache

Use this script to stop all services:

$ sudo /opt/bitnami/ctlscript.sh stop

Restart the services by running the script without any arguments:

$ sudo /opt/bitnami/ctlscript.sh restart

Obtain a list of available services and operations by running the script without any arguments:

$ sudo /opt/bitnami/ctlscript.sh

What are the default ports?

A port is an endpoint of communication in an operating system that identifies a specific process or a type of service. Bitnami stacks include several services or servers that require a port.

Remember that if you need to open some ports you can follow the instructions given in the FAQ to learn how to open the server ports for remote access.

Port 22 is the default port for SSH connections.

Bitnami opens some ports for the main servers. These are the ports opened by default: 80, 443.

Which components are installed with the Bitnami JRuby Stack?

The Bitnami JRuby 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

  • PageSpeed module
  • SQLite database
  • OpenSSL library
  • CURL library
  • OpenLDAP library

How can I get started with JRuby?

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.

$ jruby -S 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 jruby -S 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:

$ jruby -S 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 JRuby server application?

For security reasons, JRuby server applications are accessible only when using 127.0.0.1 as the hostname. To access the application, it is necessary to create an SSH tunnel by forwarding port 3000 on the JRuby server to port 3000 on the local host.

Refer to the FAQ for platform-specific instructions to create the SSH tunnel. An example of configuring the SSH tunnel using PuTTY on Windows is displayed below.

PuTTY tunnel config

How to upload files to the server with SFTP?

NOTE: Bitnami applications can be found in /opt/bitnami/apps.
NOTE: The steps below assume that your CenturyLink Cloud server has a public IP address and an open SSH port. For more information, refer to the instructions on how to configure a public IP address and open the SSH port.

The first step is to ensure that you have the SSH credentials for your server.

If you are using the Bitnami Launchpad for CenturyLink Cloud, follow these steps:

  • Browse to the Bitnami Launchpad for CenturyLink Cloud and sign in if required using your Bitnami account credentials.

  • Select the "Virtual Machines" menu item.

  • Select your cloud server from the resulting list.

  • Note the server IP address and SSH password on the resulting page. By default, the SSH username is root.

    SSH credentials

If you are using the CenturyLink Control Portal, follow these steps:

  • Browse to the CenturyLink Control Portal and sign in if required using your CenturyLink Cloud account credentials.

  • Enter the name of your server in the search box at the top of the page, or select the server from the region and group list.

  • On the server detail page, obtain the public IP address. It is important to use the public IP address and not the internal IP address.

    CenturyLink IP address

  • On the same page, click the "show admin credentials" button. Note the username and password displayed.

    SSH credentials

Although you can use any SFTP/SCP client to transfer files to your server, this guide documents FileZilla (Windows, Linux and Mac OS X), WinSCP (Windows) and Cyberduck (Mac OS X).

Using a Password

Once you have your server's SSH credentials, choose your preferred application and follow the steps below to connect to the server using SFTP.

FileZilla

Follow these steps:

  • Download and install FileZilla.
  • Launch FileZilla and use the "File -> Site Manager -> New Site" command to bring up the FileZilla Site Manager, where you can set up a connection to your server.
  • Enter your server host name.
  • Select "SFTP" as the protocol and "Ask for password" as the logon type. Specify root as the user name and enter the server password.

    FileZilla configuration

  • Use the "Connect" button to connect to the server and begin an SFTP session. You might need to accept the server key, by clicking "Yes" or "OK" to proceed.

You should now be logged into the /root directory on the server. You can now transfer files by dragging and dropping them from the local server window to the remote server window.

If you have problems accessing your server, get extra information by use the "Edit -> Settings -> Debug" menu to activate FileZilla's debug log.

FileZilla debug log

WinSCP

Follow these steps:

  • Download and install WinSCP.
  • Launch WinSCP and in the "Session" panel, select "SCP" as the file protocol.
  • Enter your server host name and specify root as the user name. Enter the corresponding password as well.

    WinSCP configuration

  • From the "Session" panel, use the "Login" button to connect to the server and begin an SCP session.

You should now be logged into the /root directory on the server. You can now transfer files by dragging and dropping them from the local server window to the remote server window.

Cyberduck

Follow these steps:

  • Select the "Open Connection" command and specify "SFTP" as the connection protocol.

    Cyberduck configuration

  • In the connection details panel, enter the server IP address, the username root and the SSH password.

    Cyberduck configuration

  • Use the "Connect" button to connect to the server and begin an SFTP session.

You should now be logged into the /root directory on the server. You can now transfer files by dragging and dropping them from the local server window to the remote server window.

How to find the MySQL database credentials?

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 JRuby from a different machine?

For security reasons, the JRuby ports in this solution cannot be accessed over a public IP address. To connect to JRuby from a different machine, you must open port 80, 443 for remote access. Refer to the FAQ for more information on this.

IMPORTANT: Making this application's network ports public is a significant security risk. You are strongly advised to only allow access to those ports from trusted networks. If, for development purposes, you need to access from outside of a trusted network, please do not allow access to those ports via a public IP address. Instead, use a secure channel such as a VPN or an SSH tunnel. Follow these instructions to remotely connect safely and reliably.

How to reset the MariaDB root password?

Please note that depending on the version you have installed, you may find the MariaDB files at /opt/bitnami/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 /opt/bitnami/ctlscript.sh stop mariadb
    
  • Start MariaDB with the following command:

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

     $ sudo /opt/bitnami/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:

$ /opt/bitnami/mariadb/bin/mysqladmin -p -u root password NEW_PASSWORD

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

Log in to the server console as the bitnami user and run the command as usual. The required environment is automatically loaded for the bitnami user. For example, this command executes a simple Ruby program:

$ jruby my_ruby_script.rb

How to create a new Rails application?

If you are using JRuby, to create a new Rails application, change to the /home/bitnami directory and initialize a new project as below. Remember to replace the APPNAME placeholder with the actual name of your project.

$ cd /home/bitnami
$ jruby -S rails new APPNAME

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

$ cd /home/bitnami/APPNAME
$ jruby -S 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.

How to deploy a new Rails application?

Using JRuby, start the Rails server by running the following command:

$ cd APPNAME
$ jruby -S 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.

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 JRuby Stack?

Log in to the server console as the bitnami user and run the gem install command. For example, run the following command to install Rake:

$ sudo jruby -S gem install rake

How to create a full backup of JRuby?

Backup

The Bitnami JRuby 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.

Follow these steps:

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

      $ cd /your/directory
    
  • Stop all servers:

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

      $ sudo tar -pczvf application-backup.tar.gz /opt/bitnami
    
  • Restart all servers:

      $ sudo /opt/bitnami/ctlscript.sh start
    

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

Restore

Follow these steps:

  • Change to the directory containing your backup:

      $ cd /your/directory
    
  • Stop all servers:

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

      $ sudo mv /opt/bitnami /tmp/bitnami-backup
    
  • Uncompress the backup file to the original directoryv

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

      $ sudo /opt/bitnami/ctlscript.sh start
    

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

How to debug errors in your database?

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

centurylink

Bitnami Documentation