{"id":8694,"date":"2015-01-07T21:53:42","date_gmt":"2015-01-07T21:53:42","guid":{"rendered":"https:\/\/wp.okra.host\/article\/setting-up-rails-with-passenger\/"},"modified":"2021-03-07T14:47:16","modified_gmt":"2021-03-07T13:47:16","slug":"setting-up-rails-with-passenger","status":"publish","type":"ht_kb","link":"https:\/\/kb.okra.host\/de\/article\/setting-up-rails-with-passenger\/","title":{"rendered":"Einrichten von Rails mit Passenger"},"content":{"rendered":"<h2 id=\"overview\" >\u00dcbersicht<\/h2>\n<p><a href=\"http:\/\/en.wikipedia.org\/wiki\/Ruby_on_Rails\">Ruby on Rails<\/a> is a web application framework built on the\u00a0Ruby programming language. <a title=\"Ermitteln der Plattformversion\" href=\"https:\/\/kb.okra.host\/de\/platform\/determining-platform-version\/\">Older hosting platforms<\/a> (&lt; v4.5) support up to Rails 2. Newer platforms before v6 support Rails 3. v6+ platforms support Rails 2-4+ and Ruby 1.8-2.2+ using <a href=\"http:\/\/rvm.io\">rvm<\/a>.<\/p>\n<p style=\"text-align: center\"><span style=\"color: #0000ff\">Need a <a title=\"Migrieren auf einen anderen Server\" href=\"https:\/\/kb.okra.host\/de\/platform\/migrating-another-server\/\">migration<\/a> to a newer platform to support Rails 4? Just open a ticket in the <a title=\"Anmeldung am Bedienfeld\" href=\"https:\/\/kb.okra.host\/de\/control-panel\/logging-into-the-control-panel\/\">Bedienfeld<\/a>!<\/span><\/p>\n<h2 id=\"getting-started\" >Einstieg<\/h2>\n<p>This guide only\u00a0covers platform versions 4.5+.<\/p>\n<h3 id=\"rails-2-on-v6-platforms\" >Rails 2+ on v6+ platforms<\/h3>\n<p>On Sol and <a title=\"Ermitteln der Plattformversion\" href=\"https:\/\/kb.okra.host\/de\/platform\/determining-platform-version\/\">newer platforms<\/a>, you can switch between Ruby versions, and install multiple Rails to suit your requirements. These platforms support Rails versions 2.0 to 4 and beyond.<\/p>\n<ol>\n<li>Log into the\u00a0<a title=\"Zugriff auf das Terminal\" href=\"https:\/\/kb.okra.host\/de\/terminal\/accessing-terminal\/\">Terminal<\/a><\/li>\n<li>Determine what version of Ruby to use with <code><a href=\"https:\/\/kb.okra.host\/de\/ruby\/changing-ruby-versions\/\">rvm use<\/a><\/code>.\n<ul>\n<li>This must be used at least once on your account to configure rvm&#8217;s shim system<br \/>\n<code>cd \/var\/www ; rvm use 2.2.2<\/code><\/li>\n<\/ul>\n<\/li>\n<li>Issue\u00a0<code>gem install --no-rdoc --no-ri passenger rails<\/code> to install Rails from the shell\n<ul>\n<li>If using an old version of Ruby (less than 2.0), specify <code>gem install -y --no-rdoc --no-ri passenger rails<\/code><\/li>\n<\/ul>\n<\/li>\n<li>Change to \/var\/www:\u00a0<code>cd \/var\/www<\/code><\/li>\n<li>Initialize a new application: <code>rails myapp<\/code><\/li>\n<li>Assign a <code>PassengerRuby<\/code> to your application\n<ul>\n<li>Generate the proper <a title=\".htaccess-Leitfaden\" href=\"https:\/\/kb.okra.host\/de\/guides\/htaccess-guide\/\">htaccess<\/a> directive with <code>passenger-config --ruby-command<\/code><\/li>\n<li>W\u00e4hlen Sie die\u00a0<em>Apache<\/em> directive, e.g. (use the italicized directive)\n<ul>\n<li>To use in Apache: <em>PassengerRuby \/.socket\/ruby\/gems\/ruby-2.1.2\/wrappers\/ruby<br \/>\n<\/em><\/li>\n<li><span style=\"color: #ff0000\"><strong>Important<\/strong><\/span>: select the PassengerRuby with <em>wrappers\/<\/em> in the path, not <em>bin\/<\/em>. The wrapper populates necessary gem environment variables<\/li>\n<\/ul>\n<\/li>\n<li>Add that <a title=\".htaccess-Leitfaden\" href=\"https:\/\/kb.okra.host\/de\/guides\/htaccess-guide\/\">Apache directive<\/a> to a file called <code>.htaccess<\/code> located within the public\/ directory, <code>\/var\/www\/myapp\/public<\/code> in this case.<\/li>\n<\/ul>\n<\/li>\n<li>Verify all dependencies are installed in \/var\/www\/myapp. This will take a few minutes to complete:\n<ul>\n<li>\n<pre data-language=\"shell\"><code>cd \/var\/www\/myapp\r\nbundle install<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<li>Connect your Rails application to a URL:\n<ul>\n<li>Visit <strong>Web<\/strong> &gt; <strong>Subdomains<\/strong> innerhalb der <a title=\"Anmeldung am Bedienfeld\" href=\"https:\/\/kb.okra.host\/de\/control-panel\/logging-into-the-control-panel\/\">Bedienfeld<\/a>. Create a new subdomain called <em>rails<\/em> with the <a title=\"Von wo aus werden die Inhalte der Website bereitgestellt?\" href=\"https:\/\/kb.okra.host\/de\/web-content\/where-is-site-content-served-from\/\">Dokumentenstamm<\/a> <code>\/var\/www\/myapp\/public<\/code>\n<\/p>\n<div id=\"attachment_412\" style=\"width: 310px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/kb.okra.host\/wp-content\/uploads\/2015\/01\/Rails-subdomain.png\" rel=\"lightbox-0\" data-lbwps-width=\"927\" data-lbwps-height=\"137\" data-lbwps-srcsmall=\"https:\/\/kb.okra.host\/wp-content\/uploads\/2015\/01\/Rails-subdomain.png\"><img decoding=\"async\" aria-describedby=\"caption-attachment-412\" loading=\"lazy\" class=\"size-medium wp-image-412\" src=\"https:\/\/kb.okra.host\/wp-content\/uploads\/2015\/01\/Rails-subdomain-300x44.png\" alt=\"Adding a Rails subdomain in the CP.\" width=\"300\" height=\"44\" \/><\/a><\/p>\n<p id=\"caption-attachment-412\" class=\"wp-caption-text\">Adding a Rails subdomain in the CP.<\/p>\n<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<li>Rails application will start in Production mode, but requires a <a href=\"http:\/\/edgeguides.rubyonrails.org\/upgrading_ruby_on_rails.html#config-secrets-yml\">secret key<\/a>. Set <code>secret_key_base<\/code> in <code>config\/secrets.yml<\/code><\/li>\n<li><em><strong>Viel Spa\u00df!<\/strong><\/em><\/li>\n<\/ol>\n<div id=\"attachment_793\" style=\"width: 284px\" class=\"wp-caption alignleft\"><a href=\"https:\/\/kb.okra.host\/wp-content\/uploads\/2015\/01\/rails-v3-installed.png\" rel=\"lightbox-1\" data-lbwps-width=\"582\" data-lbwps-height=\"637\" data-lbwps-srcsmall=\"https:\/\/kb.okra.host\/wp-content\/uploads\/2015\/01\/rails-v3-installed.png\"><img decoding=\"async\" aria-describedby=\"caption-attachment-793\" loading=\"lazy\" class=\"wp-image-793 size-medium\" src=\"https:\/\/kb.okra.host\/wp-content\/uploads\/2015\/01\/rails-v3-installed-274x300.png\" alt=\"Sample install from Rails v3 installed using Ruby 1.8\" width=\"274\" height=\"300\" \/><\/a><\/p>\n<p id=\"caption-attachment-793\" class=\"wp-caption-text\">Sample install from Rails v3 installed using Ruby 1.8<\/p>\n<\/div>\n<div id=\"attachment_795\" style=\"width: 310px\" class=\"wp-caption alignleft\"><a href=\"https:\/\/kb.okra.host\/wp-content\/uploads\/2015\/01\/rails-v4-installed.png\" rel=\"lightbox-2\" data-lbwps-width=\"807\" data-lbwps-height=\"641\" data-lbwps-srcsmall=\"https:\/\/kb.okra.host\/wp-content\/uploads\/2015\/01\/rails-v4-installed.png\"><img decoding=\"async\" aria-describedby=\"caption-attachment-795\" loading=\"lazy\" class=\"wp-image-795 size-medium\" src=\"https:\/\/kb.okra.host\/wp-content\/uploads\/2015\/01\/rails-v4-installed-300x238-1.png\" alt=\"Sample install from Rails v4 using Ruby 2.2\" width=\"300\" height=\"238\" \/><\/a><\/p>\n<p id=\"caption-attachment-795\" class=\"wp-caption-text\">Sample install from Rails v4 using Ruby 2.2<\/p>\n<\/div>\n<h3 id=\"rails-2-or-3-on-pre-v6\" >Rails 2 or 3 on pre-v6<\/h3>\n<p>Running on an older platform and nestled in your home? No problem! Rails 2 or 3 can be setup using mod_passenger and rubygems.<\/p>\n<ol>\n<li>Log into the <a title=\"Zugriff auf das Terminal\" href=\"https:\/\/kb.okra.host\/de\/terminal\/accessing-terminal\/\">Terminal<\/a><\/li>\n<li>Issue <code>gem install -v '&lt; 4.0' --no-rdoc --no-ri -y rails<\/code>\n<ul>\n<li>Ruby on Rails will install the latest available 3.x release<\/li>\n<li>&#8211;no-rdoc and &#8211;no-ri will omit documentation and irb files to reduce storage consumption<\/li>\n<li>Servers are tied to Ruby 1.9.1 (v4.5) or 1.9.3 (v5) depending upon platform<\/li>\n<\/ul>\n<\/li>\n<li>Change to \/var\/www: \u00a0<code>cd \/var\/www<\/code><\/li>\n<li>Initialize a new application:\u00a0<code>rails myapp<\/code><\/li>\n<li>Assign a <code>RailsBaseUri<\/code> und\u00a0<code>PassengerAppRoot<\/code>\u00a0for\u00a0your application\n<ul>\n<li>Both are\u00a0<a title=\".htaccess-Leitfaden\" href=\"https:\/\/kb.okra.host\/de\/guides\/htaccess-guide\/\">Apache directives<\/a>\u00a0added to a file called <code>.htaccess<\/code> located within the public\/ directory, <code>\/var\/www\/myapp\/public<\/code> in this case.<\/li>\n<li>For RailsBaseUri, specify the directive: <code>RailsBaseUri \/<\/code><\/li>\n<li>For PassengerAppRoot, take the HTTP base path within the control panel under <strong>Konto<\/strong> &gt; <strong>Zusammenfassung<\/strong> &gt; <strong>Web<\/strong> &gt; <strong>HTTP Base Path<\/strong>. PassengerAppRoot is the <em>HTTP Base Path<\/em> + <em>App\u00a0Path in Terminal<\/em>, e.g.\n<ul>\n<li><code>PassengerAppRoot \/home\/virtual\/site12\/fst\/var\/www\/myapp<\/code><\/li>\n<\/ul>\n<\/li>\n<li>Add \u00a0both lines to your <code>.htaccess<\/code> Datei.<\/li>\n<\/ul>\n<\/li>\n<li>Edit <code>environment.rb<\/code> in <code>myapp\/environments\/<\/code> to load sqlite3.\n<ul>\n<li>Navigate to <strong>Rails::Initializer<\/strong> and add config.gem:\n<pre class=\"ruby code\" data-language=\"ruby\"><code>Rails::Initializer.run do |config|\r\n   # Settings in config\/environments\/* take ...\r\n   # Comments ...\r\n\u00a0\r\n   config.gem \"sqlite3\"\r\n\u00a0\r\n   # more comments ...\r\nend<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<li>Connect your Rails application to a URL:\n<ul>\n<li>visit <strong>Web<\/strong> &gt; <strong>Subdomains<\/strong> innerhalb der <a title=\"Anmeldung am Bedienfeld\" href=\"https:\/\/kb.okra.host\/de\/control-panel\/logging-into-the-control-panel\/\">Bedienfeld<\/a>. Create a new subdomain called <em>rails<\/em> with the <a title=\"Von wo aus werden die Inhalte der Website bereitgestellt?\" href=\"https:\/\/kb.okra.host\/de\/web-content\/where-is-site-content-served-from\/\">Dokumentenstamm<\/a> <code>\/var\/www\/myapp\/public<\/code>\n<\/p>\n<div id=\"attachment_412\" style=\"width: 310px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/kb.okra.host\/wp-content\/uploads\/2015\/01\/Rails-subdomain.png\" rel=\"lightbox-0\" data-lbwps-width=\"927\" data-lbwps-height=\"137\" data-lbwps-srcsmall=\"https:\/\/kb.okra.host\/wp-content\/uploads\/2015\/01\/Rails-subdomain.png\"><img decoding=\"async\" aria-describedby=\"caption-attachment-412\" loading=\"lazy\" class=\"size-medium wp-image-412\" src=\"https:\/\/kb.okra.host\/wp-content\/uploads\/2015\/01\/Rails-subdomain-300x44.png\" alt=\"Adding a Rails subdomain in the CP.\" width=\"300\" height=\"44\" \/><\/a><\/p>\n<p id=\"caption-attachment-412\" class=\"wp-caption-text\">Adding a Rails subdomain in the CP.<\/p>\n<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<li><em><strong>Viel Spa\u00df!<\/strong><\/em><\/li>\n<\/ol>\n<h2 id=\"switching-environments\" >Switching environments<\/h2>\n<p>By default, Rails applications start in production mode, which ratchets down verbosity and runs faster than development mode. During the course of development it may be necessary to change to development mode to facilitate debugging or testing out interim features. To make a change, add\u00a0<code>SetEnv RAILS_ENV development<\/code> to your <a title=\".htaccess-Leitfaden\" href=\"https:\/\/kb.okra.host\/de\/guides\/htaccess-guide\/\">.htaccess<\/a> file located within the public\/ folder of the application.<\/p>\n<h2 id=\"restarting-your-app\" >Restarting your app<\/h2>\n<p>An app may either be restarted upon each request or at a single point. To restart an app every invocation, create a file called always_restart.txt in tmp\/: <code>touch tmp\/always_restart.txt<\/code>. To perform a single restart, create a file called restart.txt in tmp\/: <code>touch tmp\/restart.txt<\/code>. Passenger, which handles\u00a0process management, will compare the timestamp with its internal record and restart as necessary. To restart a second time, either reissue the command or delete, then recreate the file to update its modification time.<\/p>\n<h2 id=\"viewing-launcher-errors\" >Anzeige von Fehlern im Startprogramm<\/h2>\n<p>On newer v6 platforms, launcher errors may be viewed through the consolidated log file, <code>\/var\/log\/passenger.log<\/code>.<\/p>\n<h2 id=\"see-also\" >Siehe auch<\/h2>\n<ul>\n<li><a href=\"http:\/\/guides.rubyonrails.org\/index.html\">Ruby on Rails Guides<\/a><\/li>\n<li><a href=\"https:\/\/www.railstutorial.org\/book\">Ruby on Rails Tutorial<\/a>: Learn Web Development with Rails e-book<\/li>\n<li><a href=\"http:\/\/daniel.fone.net.nz\/blog\/2013\/05\/20\/a-better-way-to-manage-the-rails-secret-token\/\">A better way to manage the Rails secret token<\/a><\/li>\n<li>Concurrent implementations of Rails <a href=\"http:\/\/rails2.futz.net\">v2<\/a>, <a href=\"http:\/\/rails3.futz.net\">v3<\/a>, und <a href=\"http:\/\/rails4.futz.net\">v4<\/a>\u00a0on <a href=\"http:\/\/apnscp.com\/server-lookup?domain=futz.net\">Sol<\/a> (v6 platform)<\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Overview Ruby on Rails is a web application framework built on the\u00a0Ruby programming language. Older hosting platforms (&lt; v4.5) support up to Rails 2. Newer platforms before v6 support Rails 3. v6+ platforms support Rails 2-4+ and Ruby 1.8-2.2+ using rvm. Need a migration to a newer platform to support&#8230;<\/p>","protected":false},"author":1,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"ht-kb-category":[66],"ht-kb-tag":[],"class_list":["post-8694","ht_kb","type-ht_kb","status-publish","format-standard","has-post-thumbnail","hentry","ht_kb_category-ruby"],"_links":{"self":[{"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/ht-kb\/8694","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/comments?post=8694"}],"version-history":[{"count":2,"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/ht-kb\/8694\/revisions"}],"predecessor-version":[{"id":8699,"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/ht-kb\/8694\/revisions\/8699"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/media\/8697"}],"wp:attachment":[{"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/media?parent=8694"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/ht-kb-category?post=8694"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/ht-kb-tag?post=8694"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}