Bitnami Rubystack 1.9.3-0 Quick Start Guide
Bitnami Rubystack 1.9.3-0 Quick Start Guide
3-0
Quick Start Guide
This product and its documentation are protected by copyright. The information in this document is provided on an
"as is" basis, without warranty. Although every precaution has been taken in the preparation of this document, the
authors will not have any liability to any person or entity with respect to any loss or damage caused or alleged to be
caused directly or indirectly by the information contained in this work.
Trademark names may appear in this document. All registered and unregistered trademarks in this document are the
sole property of their respective owners.
Acknowledgements
BitNami RubyStack is based on a number of open source components:
Ruby. The interpreted scripting language for quick and easy object-oriented programming.
http://www.ruby-lang.org/.
Rails. Together with Ruby (RoR) is a open-source web application framework that's optimized for programmers
happiness and sustainable productivity.
http://www.rubyonrails.org/.
MySQL. The world's leading open source database.
http://www.mysql.com
The Apache HTTP server, developed by The Apache Software Foundation.
http://www.apache.org/.
PHP. The widely used scripting language.
http://www.php.net.
The open source browser-based MySQL management tool phpMyAdmin.
http://www.phpmyadmin.net
Git. Open source, distributed version control system.
http://git-scm.com
Subversion. The open-source version control system.
http://www.subversion.tigris.org
RubyGems. The premier ruby packaging system
http://rubygems.org/
Phusion Passenger (a.k.a. mod_rails or mod_rack) makes deployment of Ruby web applications a breeze.
http://www.modrails.com/.
Nginx. High-performance HTTP server and reverse proxy.
http://nginx.org/.
Sphinx. Full-text search engine.
http://www.sphinxsearch.com/.
Memcached. High-performance, distributed memory object caching system.
http://www.memcached.org/.
The OpenSSL library for encrypting communications.
http://www.openssl.org/.
The zlib data-compression library.
http://www.zlib.net
You can find the individual licenses for the above projects as part of the installation.
Components
BitNami RubyStack includes Apache 2.2.23, ImageMagick 6.7.5, MySQL 5.5.28, Ruby 1.9.3-p327, Rails 3.2.9,
RubyGems 1.8.12, PHP 5.4.8, phpMyAdmin 3.5.3, Git 1.7.11.3, Subversion 1.7.5, nginx 1.2.4 and more
requeriment libraries.
Ruby is a dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant
syntax that is natural to read and easy to write. You can learn more about Ruby at http://www.ruby-lang.org.
Ruby on Rails is a full-stack MVC framework for database-backed web applications that's optimized for programmer
happiness and sustainable productivity. It lets you write beautiful code by favoring convention over configuration. You
can learn more about Ruby at http://www.rubyonrails.org.
Apache is the most popular HTTP server on the Internet. It provides a secure, efficient and extensible web platform.
It is maintained by the Apache Software Foundation. You can find more information about Apache at
http://www.apache.org.
MySQL is the world's most popular open source database. It is a relational database management system that
combines speed, reliability and ease of use. It is developed and maintained by MySQL AB. You can find more
information about MySQL at http://www.mysql.com.
PHP is a web development scripting language that can be embedded into HTML. Powerful and easy to use, it is the
most popular Apache module. It is maintained by the PHP Group. You can find more information about PHP at
http://www.php.net.
phpMyAdmin is a tool written in PHP intended to handle the administration of MySQL through a web interface. It
allows you to manage anything from a single database to a complete MySQL server. You can find more information
about phpMyAdmin at http://www.phpmyadmin.net.
Git is a free & open source, distributed version control system designed to handle everything from small to very large
projects with speed and efficiency. You can find more information about Git at http://git-scm.com/.
Subversion The goal of the Subversion project is to build a version control system that is a compelling replacement
for CVS in the open source community. The software is released under an Apache/BSD-style open source license.
http://subversion.tigris.org/.
Phusion Passenger (a.k.a. mod_rails or mod_rack) makes deployment of Ruby web applications, such as those
built on the revolutionary Ruby on Rails web framework, a breeze. It follows the usual Ruby on Rails conventions,
such as "Don?t-Repeat-Yourself". You can find more information about Passenger at http://www.modrails.com/.
Nginx is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy
server. It is known for its high performance, stability, rich feature set, simple configuration, and low resource
consumption. You can find more information about Nginx at http://nginx.org/.
Sphinx is a full-text search engine, meant to provide fast, size-efficient and relevant fulltext search functions to other
applications. Sphinx was specially designed to integrate well with SQL databases and scripting languages. You can
find more information about Sphinx at http://www.sphinxsearch.com/.
Memcached free & open source, high-performance, distributed memory object caching system, generic in nature,
but intended for use in speeding up dynamic web applications by alleviating database load. Memcached is an inmemory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls,
or page rendering. You can find more information about Memcached at http://www.memcached.org/.
Ruby Version Manager (RVM) is a command-line tool which allows you to easily install, manage, and work with
multiple ruby environments from interpreters to sets of gems. You can find more information about RVM at
https://rvm.io/
Requirements
To run BitNami RubyStack you will need:
Intel x86 or compatible processor
Minimum of 512 MB RAM
Minimum of 150 MB hard drive space
A Windows operating system
TCP/IP protocol support
An x86 Linux operating system or
A 32-bit Windows operating system such as Windows 2000, XP, Vista or Windows Server 2003 or
an OS X operating System.
Installation Guide
This section describes where to download BitNami RubyStack and the different installation modes that are available.
Directory Structure
The installation process will create several subfolders under the main installation directory:
mysql/: MySQL Database.
sqlite/: SQLite Database.
ruby/: Ruby and ruby gems files.
img/: Additional image files and icons.
imagemagick/: ImageMagick image proccessor.
subversion/: Subversion files.
scripts/: Script with enviroment vars.
licenses/: Component licenses.
apache2/: Apache2 files.
php/: PHP files.
apps/phpMyAdmin/: phpMyAdmin files.
nginx/: nginx files.
memcached/: Memcached files.
sphinx/: Sphinx files.
git/: git files.
Ruby on Rails
On this section we are going to assume that Rubystack has been installed at C:\Rubystack-1.9.3-0\ on Windows,
/home/user/rubystack on Linux or /Applications/rubystack/projects/ on OS X and your Rails application
name is rubystack.
This part of the tutorial has been written following a Questions and Answers model.
How do I start doing things with RubyStack?
The first thing you must do is to run a Rails Environment by selecting:
Start -> BitNami RubyStack -> Use Ruby on Windows or
/home/user/rubystack/rubyconsole on Linux or OS X.
That will open a console window with a properly setup environment where you can then issue
commands.
How do I launch or stop MySQL and Apache services?
BitNami ships a Manager Tool that is a simple graphical interface that can start and stop the
BitNami servers that are located in the same installation directory. To start the utility, double click
the file named 'manager-windows','manager-linux' or 'manager-osx' from your file browser.
Another option is to use the command line. On Windows, open the Rails Environment and then run
the servicerun.bat script to start or stop the services. In order to start services you must run:
servicerun.bat START
Be sure you are in the main directory of the RubyStack installation (C:\RubyStack-1.9.3-0\).
On Linux or OS X, you can start/stop Apache, MySQL and Subversion server with ctlscript.sh. You
can type ./ctlscript.sh help to see all options:
usage: ./ctlscript.sh help
./ctlscript.sh
./ctlscript.sh
./ctlscript.sh
./ctlscript.sh
(start|stop|restart)
(start|stop|restart) mysql
(start|stop|restart) apache
(start|stop|restart) subversion
which is also the location that the "Use Ruby" console starts at.
cd rubystack
ruby script/rails server
If you are using a previous version (Rails 2.X), the command that you should execute is the
following:
cd rubystack
ruby script/server
That will create a directory called my_new_app with the correponding files inside. The next step is to
create databases for that application, which is explained below.
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 RubyStack into the
"Gemfile":
...
gem 'sqlite3'
gem 'therubyracer'
...
How can I create the correponding databases for my new web application?
Open a Rails Environment window and connect to the mysql database:
"C:\RubyStack-1.9.3-0\mysql\bin\mysql.exe" -u root --port=your-port-here on
How can I configure my new Rails application to use the previously created databases?
You need to create a file called "database.yml" inside of your web application config directory. In
order to do that, open "notepad" or your preferred text editor and paste the following on Windows:
development:
adapter: mysql
database: my_new_app_development
username: rubystack
password: your-password-here
host: localhost
port: ${mysql_port}
test:
adapter: mysql
database: my_new_app_test
username: rubystack
password: your-password-here
port: ${mysql_port}
production:
adapter: mysql
database: my_new_app_production
username: rubystack
password: your-password-here
port: ${mysql_port}
RVM
RVM is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments
from interpreters to sets of gems.
Managing Rubies
The main feature of RVM is its avility to manage Ruby interpreters.
As the message details, if you have not yet manually installed any Ruby, the list will be empty. After
Or simply
$ ruby --version
ruby 1.9.2p320 (2012-04-20 revision 35421) [i386-darwin11.2.0]
It is also possible to use the system Ruby (the main Ruby installed with the Stack, not through
RVM) by executing:
$ rvm use system
Now using system ruby.
...
# MRI Rubies
...
[ruby-]1.8.7-head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p320]
...
[ruby-]1.9.3-[p194]
[ruby-]1.9.3-head
ruby-head
To install a new Ruby from the list, for example 'ruby-1.9.1-p431', you just have to execute:
$ rvm install ruby-1.9.1-p431
RVM will take care of downloading, unpacking and compiling the requested Ruby
In the example, two gemsets are available, global (the default gemset will the gems that are
available to all other gemsets) and "project-sample", a custom gemset create for our 'sample'
project.
How to select a gemset for a given ruby
After selecting the desired Ruby and listing the available gemsets, you can use an specific set of
gems through the 'use' subcommand: $ rvm gemset list
gemsets for ruby-1.9.3-p194 (found in /opt/rubystack-3.2.3-0/rvm/gems/ruby-1.9.3-
p194)
global
project-sample
$ rvm gemset use project-sample
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 RubyStack on Windows, you can't start multiple servers using '.-s' option. You will need to call a
command for each instance:
cd ${rails_application_dir} thin -p 3000 -e production --prefix /appname start thin -p 3001 -e
production --prefix /appname start ...
That way, each time a Rails request is received it will be sent to the thin servers running in ports 3001, 3002..
After restarting Apache the application should be accessible at http://domain:port/appname.
<VirtualHost *:80>
ServerName myapplication.com
DocumentRoot ${rails_app_dir}/public
<Directory ${rails_app_dir}/public>
Allow from all
Options -MultiViews
</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 ${installdir}/webapps
ln -s ${installdir}/app/railsapp1/public ${installdir}/webapps/railsapp1
ln -s ${installdir}/app/railsapp2/public ${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>
Allow from all
Options -MultiViews
</Directory>
RailsBaseURI /railsapp1
RailsBaseURI /railsapp2
...
</VirtualHost>
In this case, it is not necessary to start additional processes appart from Nginx. After restarting Nginx, the application
will be accessible at http://domain:nginx_port/.
It is also possible to deploy a set of applications to different sub URIs. If you want to use this approach, you should
create symbolic links to each application public directory, inside a root path.
ln -s /path/to/rails_app/public /websites/phusion/railsapp
ln -s /path/to/rails_app2/public /websites/phusion/railsapp2
Then, include a passenger_base_uri option for each of them inside the server element:
server {
...
root /websites/phusion;
passenger_enabled on;
passenger_base_uri /railsapp;
passenger_base_uri /railsapp2;
...
}
The second step will be to create a new empty repository, we need to type the following:
git init
PHP
This section describes how to test your PHP installation. You can find the PHP technical documentation at
http://www.php.net/manual/en/index.php
Save the file as phptest.php in C:\RubyStack-1.9.3-0\apache2\htdocs\on Windows or /home/user/rubystack1.9.3-0/apache2/htdocs on Linux or /Applications/rubystack-1.9.3-0/apache2/htdocs/. Make sure Apache
is up and running, open a browser and type http://127.0.0.1:8080/phptest.php. You should then see a screen
showing detailed information about the PHP version you are using.
phpMyAdmin
This sections describes how to access your phpMyAdmin installation. You can find more information about
phpMyAdmin in http://www.phpmyadmin.net/home_page/docs.php
phpMyAdmin is an easy to use management tool for MySQL that allows you to create and drop databases, create,
drop and modify tables, delete, edit and add fields, execute SQL statements, manage keys on fields, manage
privileges and export data in various formats through a web-based interface.
Access to phpMyAdmin
To test your phpMyAdmin installation first make sure that your Apache and MySQL servers are up and running. You
can access your phpMyAdmin installation by opening a browser and typing http://127.0.0.1:8080/phpmyadmin. You
will then asked for a username and password. As user name, use "root" and as password use the value specified
during installation.
Initially only requests from 127.0.0.1 will be allowed access to that section. You can change this behavior editing the
Apache main configuration file located at C:\RubyStack-1.9.3-0\apache2\conf\httpd.conf on Windows or
/home/user/rubystack-1.9.3-0/apache2/conf/httpd.conf on Linux or /Applications/rubystack-1.9.30/apache2/conf/httpd.conf on oS X.
Troubleshooting
This section describes some of the most common problems you may find when installing BitNami RubyStack.
Installer
Installer Payload Error
You may get the following error while trying to run the installer from the command line:
Installer payload initialization failed. This is likely due to an incomplete or corrupt
downloaded file.
The installer binary is not complete, likely because the file was not downloaded correctly. You will need to download
the file and repeat the installation process.
Installation does not complete and hangs at the end forever.
You are probably overwriting a previous RubyStack installation and therefore a previous MySQL with a different
MySQL root password. Remove or move your previous RubyStack installation and try to install RubyStack again.
MySQL
If you encounter any problems starting MySQL, the first place to look in is the "Problems and Common Errors"
section of the MySQL manual, which you will find at http://dev.mysql.com/doc/
The following are some common problems:
Access denied when trying to connect to MySQL.
If you get an Access Denied message while trying to connect to MySQL, make sure you are using the correct
username and password.
"Can't connect to server" message.
Make sure the MySQL daemon is up and running.
Apache
If you find any problem starting Apache, the first place you should look at is the error log file that will be created at
C:\RubyStack-1.9.3-0\apache2\logs\error_log on Windows or /home/user/rubystack-1.9.30/apache2/logs/error_log on Linux or /Applications/rubystack-1.9.3-0/apache2/logs/error_log on OS
X. There you will likely find useful information to determine what the problem may be. For issues not covered in this
Quick Start guide, please refer to the Apache documentation included as part of the installation, which is located at
apache2/htdocs/manual.
Test page is not working
If the server seems to start correctly (i.e. you can see the ./apachectl start: httpd started message) but you
cannot see the test page when you type http://127.0.0.1:80/ on Windows or http://127.0.0.1:8080/ on Linux in your
browser, it may be that there is already a server running in that port.