ABET Project for EAS Comm Office
We were approached by the E&AS Communications Office to provide them with a platform for them to complete their ABET project (Accreditation Board for Engineering and Technology).
Specifically, they wanted a web platform that:
- is stable.
- is secure.
- has Ruby on Rails 3.
Technical details
Getting Ruby on Rails with Apache working is relatively easy. However, this won't get you publicly accessible pages. For that, Passenger needs to be installed. This is where the real
fun begins...
Using openSUSE Studio, I've created install images with
most of the software needed:
apache2
apache2-devel
libapr1-devel
libapr-util1-devel
libopenssl-devel
libcurl-devel
gcc-c++
make
git
ruby
rubygem-bundler
rubygem-mysql
rubygem-passenger
rubygem-rack
rubygem-rails-3_0
Studio installs any dependent packages as necessary.
Configuration
In the case more detailed info is needed, you should be able to find it
here at the modrails site.
When the system is booted the first time, you'll need to
build the actual passenger module for Apache to use:
/usr/lib/ruby/gems/1.8/gems/passenger-3.0.0/bin/passenger-install-apache2-module
This is a script that came with the passenger Ruby gem to check for needed executables that compile and install the passenger Apache module. (This is a required step unless you'd like to install Passenger by hand, which will be
much more time-consuming.)
When done, you should see:
....
--------------------------------------------
The Apache 2 module was successfully installed.
Please edit your Apache configuration file, and add these lines:
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.0/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.0
PassengerRuby /usr/bin/ruby
After you restart Apache, you are ready to deploy any number of Ruby on Rails
applications on Apache, without any further Ruby on Rails-specific
configuration!
Press ENTER to continue.
--------------------------------------------
Deploying a Ruby on Rails application: an example
Suppose you have a Rails application in /somewhere. Add a virtual host to your
Apache configuration file and set its DocumentRoot to /somewhere/public:
<VirtualHost *:80>
ServerName www.yourhost.com
DocumentRoot /somewhere/public # <-- be sure to point to 'public'!
<Directory /somewhere/public>
AllowOverride all # <-- relax Apache security settings
Options -MultiViews # <-- MultiViews must be turned off
</Directory>
</VirtualHost>
And that's it!
In
/etc/apache2/conf.d/mod_passenger.conf
, insert the block of text above starting with
LoadModule
.
Next, create the developer's desired namespace for deployment under
DocumentRoot (normally
/srv/www/htdocs
). For this project, it is:
/srv/www/htdocs/staging/releases
/srv/www/htdocs/staging/shared
Then, in the
VirtualHost directive they are exposed as:
<VirtualHost *:80>
ServerName www.somename.com
DocumentRoot /srv/www/htdocs/staging/current/public
RailsEnv Staging
RailsBaseURI /
<Directory /srv/www/htdocs/staging/current/public>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
On the production system, replace "staging" with "production".
If the developer is using the "Capistrano" Ruby gem, as in the case of this project, you'll need to create an SSH key for use with it, as well as give that user write access to the
DocumentRoot mentioned above. ASSIGN THIS SSH KEY A PASSPHRASE!! Password/Passphrase-less SSH keys are evil evil evil.
NOTE: You may also want to
chmod
and
chown
the
~/.ssh
directory and files to prevent the user from overwriting them to create passphrase-less SSH keys.
Of course, the SSH key should be the same on both machines, development and production.
--
DavidLeBlanc - 2019-10-04