Ruby on Rails deployment to Plesk/SuSE VPS

Last night I wanted to deploy my fresh Rails application to my virtual private server.

It wasn’t as easy as I initially thought, but with a little help from google, I managed to get it running. Of course, there is still a bit to do, but before I forget all the steps, I wanted them to be safe in this article.

For the moment I have it running using sqlite3, but I will switch to MySQL quite soon, so you may need to adjust the steps accordingly.

This solution is based on Passenger

Software Preperation

You may be tempted to use YAST to install all Ruby/Rails related components. I strongly discourage you to do so, since I did and it failed. On my SuSE (10.3) all packages where to much outdated, so that I even couldn’t use gem to install e.g. passenger.

  • The following packages need to be installed from YAST:
    • Ruby (1.8.6) from YAST seems to be recent enough
    • sqlite and sqlite-devel
    • apache-devel
    • c++ (gcc)
  • Download the *.tgz of RubyGems (1.3.5) from RubyGem, then do:
    • tar -xzvf  rubygems-1.3.5.tgz
    • cd rubygems-1.3.5
    • ruby setup.rb
  • Install Rails (2.3.5)
    • gem install rails
  • Install Passenger
    • gem install passenger
    • passenger-install-apache2-module
    • put:
      LoadModule passenger_module /usr/lib64/ruby/gems/1.8/gems/passenger-2.2.9/ext/apache2/mod_passenger.so
      PassengerRoot /usr/lib64/ruby/gems/1.8/gems/passenger-2.2.9
      PassengerRuby /usr/bin/ruby
      into /etc/apache2/conf.d/passenger.conf
  • Install sqlite3
    • gem install sqlite3-ruby
  • You may need to install more project related gems according to your application

Create Site and deploy

  • Create a new domain with Plesk’s webinterface
    • Goto Domains and follow the process on Create Domain (Important: You need FTP-access to your new site)
  • Connect to your site with your favourite FTP-Client
  • Goto httpdocs of your new site and wipe out all content
  • Deploy your application via FTP to the empty folder httpdocs

Setup Apache

  • Put:
    ServerName YourDomain
    DocumentRoot /srv/www/vhosts/YourDomain/httpdocs/public
    <Directory /srv/www/vhosts/YourDomain/httpdocs/public/>
    AllowOverride all
    Options -MultiViews
    </Directory>
    the new file /srv/www/vhosts/YourDomain/conf/vhost.conf
  • Make Plesk aware of your settings (Plesk discourages you from editing their config files, therefore you have put it into your own vhost.conf) and run:
    • /usr/local/psa/admin/sbin/websrvmng -u –vhost-name=YourDomain

Migrate and make it work

  • cd /srv/www/vhosts/YourDomain/httpdocs
  • rake db:migrate RAILS_ENV=”production” –trace
  • chown -R wwwrun:www /srv/www/vhosts/YourDomain/httpdocs
  • Take your favourite browser and navigate to your new and shiny application

I got to this solution by trial and error and I’m not 100% sure whether I remember all the steps, so there might be some glitches left for you to sort out. But it should cover most topics.

Future plans is to get it running using MySQL and RubyEnterpriseEdition

This are some of the blogs and sites, that helped me out:

Have fun!

Schlagworte: , , , , , , ,

2 Kommentare zu „Ruby on Rails deployment to Plesk/SuSE VPS“

  1. Ortwin sagt:

    Hi Alex,

    hast du eventuell schon mal redmine in einer Pleskdomain bzw. Subdomain installiert?

    Ich würde das gerne für http://conrepo.org machen, z.B. unter http://dev.conrepo.org, habe aber mit ruby noch garnichts am Hut.
    Vielleicht hast du ja da ein paar Tips für mich. :-)

    Gruß aus Franken

    Ortwin

  2. blogadmin sagt:

    Servus Ortwin,

    habe mit redmine noch nicht gearbeitet, aber ich habe in der tat einen kleinen Tip für Dich.

    Wenn Du die Plesk nicht aus dem Takt bringen willst, dann musst Du Deine Domain mit Plesk anlegen. Editiere jedoch nicht die üblichen Apache-Dateien, wie in /etc/apache/vhosts.d/, sondern editiere stattdessen /srv/www/vhosts//conf/vhost.conf. Ansonsten kannst Du der Dokumentation von z.B. redgate folgen.

    Was Ruby betrifft, so musst die verschiedenen Abhängigkeiten auflösen (hat mich einen Tag gekostet). Wichtig ist, das Ruby um seinen Compile-Prozess zu fahren, die verschiedenen “dev”-Paketet braucht. (Zumindest auf SuSE), da hier die entsprechenden Bibliotheken enthalten sind.

    Abschließend kann ich Dir nur mitgeben, dass seitdem ich mit Ruby durch bin, keine Schwierigkeiten mehr hatte.

    Grüße aus Frankfurt!

    Alex

Kommentieren