{"id":73,"date":"2025-05-12T22:09:43","date_gmt":"2025-05-12T22:09:43","guid":{"rendered":"http:\/\/abmservermanagement.com.au\/?p=73"},"modified":"2025-05-12T22:09:43","modified_gmt":"2025-05-12T22:09:43","slug":"installing-ruby-on-ubuntu","status":"publish","type":"post","link":"http:\/\/abmservermanagement.com.au\/index.php\/2025\/05\/12\/installing-ruby-on-ubuntu\/","title":{"rendered":"Installing Ruby on Ubuntu"},"content":{"rendered":"\n<p>Ruby Install guide stage 1:<\/p>\n\n\n\n<p>To install Ruby on Ubuntu and configure it with Apache, you&#8217;ll first need to install Ruby and its dependencies, then configure Apache to use Ruby&#8217;s mod_ruby or a suitable alternative like mod_passenger. You can achieve this by using the APT package manager or a version manager like Rbenv.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Install Ruby:<\/li>\n<\/ol>\n\n\n\n<p>Using APT.<\/p>\n\n\n\n<p>Code<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update\n\nsudo apt install ruby-full<\/code><\/pre>\n\n\n\n<p>This installs Ruby, RubyGems, and other essential dependencies.<\/p>\n\n\n\n<p>Using Rbenv:<br>Install dependencies:<br>Code<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>    sudo apt update\n\n    sudo apt install git curl libssl-dev libreadline-dev zlib1g-dev autoconf bison build-essential libyaml-dev libreadline-dev libncurses5-dev libffi-dev libgdbm-dev<\/code><\/pre>\n\n\n\n<p>Install Rbenv:<\/p>\n\n\n\n<p>Code<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>     curl -fsSL https:\/\/github.com\/rbenv\/rbenv-installer\/raw\/HEAD\/bin\/rbenv-installer | bash<\/code><\/pre>\n\n\n\n<p>Configure Rbenv:<\/p>\n\n\n\n<p>Code<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>    echo 'export PATH=\"$HOME\/.rbenv\/bin:$PATH\"' &gt;&gt; ~\/.bashrc\n\n    echo 'eval \"$(rbenv init -)\"' &gt;&gt; ~\/.bashrc\n\n    source ~\/.bashrc<\/code><\/pre>\n\n\n\n<p>Install a Ruby version:<\/p>\n\n\n\n<p>Code<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>    rbenv install 3.2.3\n\n    rbenv global 3.2.3\n\n\n\n    rbenv install 3.4.2\n\n    rbenv global 3.4.2<\/code><\/pre>\n\n\n\n<p>(Replace 3.2.3 with the desired Ruby version).<\/p>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>Configure Apache:<\/li>\n<\/ol>\n\n\n\n<p>Install Apache.<\/p>\n\n\n\n<p>Code<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install apache2<\/code><\/pre>\n\n\n\n<p>Install mod_ruby (if using that method).<\/p>\n\n\n\n<p>Code<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install libapache2-mod-ruby2.7<\/code><\/pre>\n\n\n\n<p>Configure Apache (example with mod_ruby):<\/p>\n\n\n\n<p>Create a virtual host configuration file (e.g., \/etc\/apache2\/sites-available\/my-ruby-site.conf):<\/p>\n\n\n\n<p>Code<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>     &lt;VirtualHost *:80&gt;\n\n        ServerName your_domain.com\n\n        DocumentRoot \/var\/www\/my-ruby-site\n\n\n\n        &lt;Directory \/var\/www\/my-ruby-site&gt;\n\n            Options Indexes FollowSymLinks MultiViews\n\n            AllowOverride None\n\n            Require all granted\n\n            RubyInit \/usr\/local\/bin\/ruby # or the path to your ruby\n\n         &lt;\/Directory&gt;\n\n\n\n        RewriteEngine On\n\n        RewriteRule ^\/app\/(.*) \/index.rb?path=$1 &#91;L]\n\n    &lt;\/VirtualHost&gt;<\/code><\/pre>\n\n\n\n<p>Enable the virtual host:<\/p>\n\n\n\n<p>Code<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>    sudo a2ensite my-ruby-site.conf\n\n    sudo apache2ctl restart<\/code><\/pre>\n\n\n\n<p>STAGE 2:<\/p>\n\n\n\n<p>To configure Passenger with Apache, you need to add specific configuration snippets to your Apache configuration file, typically httpd.conf or apache2.conf. You can achieve this by using the<br>command, which will guide you through the process and provide the necessary snippets.<\/p>\n\n\n\n<p>Steps:<br>Install Passenger: Make sure you have Passenger installed.<\/p>\n\n\n\n<p>Run the installer: Execute the passenger-install-apache2-modcd \/etc\/apache2<br>command in your terminal.<\/p>\n\n\n\n<p>Follow the prompts: The installer will guide you through the process, including asking you to copy and paste the generated configuration snippets into your Apache configuration file.<\/p>\n\n\n\n<p>Identify the configuration file: Determine the location of your Apache configuration file (e.g., \/etc\/httpd\/httpd.conf or \/etc\/apache2\/apache2.conf).<\/p>\n\n\n\n<p>Add the snippets: Open the configuration file and paste the LoadModule directive and the other Passenger configuration options provided by the installer.<\/p>\n\n\n\n<p>Enable the module: Use the command sudo a2enmod passenger (or similar, depending on your system) to enable the Passenger module, says the Phusion Passenger documentation .<\/p>\n\n\n\n<p>Restart Apache: Restart your Apache server to apply the changes.<\/p>\n\n\n\n<p>Example snippets:<\/p>\n\n\n\n<p>The passenger-install-apache2-module command will generate snippets similar to these:<\/p>\n\n\n\n<p>Code<br>LoadModule passenger_module \/path\/to\/passenger\/lib\/httpd\/mod_passenger.so PassengerRoot \/path\/to\/passenger PassengerRuby \/path\/to\/ruby\/bin\/ruby PassengerAppRoot \/path\/to\/your\/rails\/app # Other Passenger settings<\/p>\n\n\n\n<p>Notes:<br>Replace \/path\/to\/passenger, \/path\/to\/ruby\/bin\/ruby , and \/path\/to\/your\/rails\/app with the actual paths to your Passenger installation, Ruby interpreter, and Rails application, respectively.<\/p>\n\n\n\n<p>The exact snippets and commands may vary slightly depending on your operating system, Apache version, and Passenger version.<\/p>\n\n\n\n<p>LoadModule passenger_module \/root\/.rbenv\/versions\/3.4.2\/lib\/ruby\/gems\/3.4.0\/gems\/passenger-6.0.27\/buildout\/apache2\/mod_passenger.so<br>PassengerRoot \/root\/.rbenv\/versions\/3.4.2\/lib\/ruby\/gems\/3.4.0\/gems\/passenger-6.0.27 PassengerDefaultRuby \/root\/.rbenv\/versions\/3.4.2\/bin\/ruby<\/p>\n\n\n\n<p>Stage 3:<\/p>\n\n\n\n<p>I have come across a cleaner solution today. This might help future users. The command &#8211;<\/p>\n\n\n\n<p>passenger-install-apache2-module<br>tells me to put these three lines in apache configuration file.<\/p>\n\n\n\n<p>LoadModule passenger_module \/root\/.rbenv\/versions\/3.4.2\/lib\/ruby\/gems\/3.4.0\/gems\/passenger-6.0.27\/buildout\/apache2\/mod_passenger.so<br>PassengerRoot \/root\/.rbenv\/versions\/3.4.2\/lib\/ruby\/gems\/3.4.0\/gems\/passenger-6.0.27 PassengerDefaultRuby \/root\/.rbenv\/versions\/3.4.2\/bin\/ruby<\/p>\n\n\n\n<p>But, where is that configuration file? The answer is the configuration files are seperated into many pieces and they reside in \/etc\/apache2\/mods-available.<\/p>\n\n\n\n<p>So you should do three things &#8211;<\/p>\n\n\n\n<p>Create a file ending with .load in \/etc\/apache2\/mods-available folder. I used passenger.load.<\/p>\n\n\n\n<p>Paste the three lines in that file and save the file.<\/p>\n\n\n\n<p>Now in terminal use sudo a2enmod to enable the module. In my case, the file was, passenger.load. So, I used<\/p>\n\n\n\n<p>sudo a2enmod passenger<br>Now, restart the server and use the command apache2ctl -M to find that passenger module is enabled.<\/p>\n\n\n\n<p>Stage 4:<\/p>\n\n\n\n<p>to apache2.conf:<\/p>\n\n\n\n<p>AddHandler application\/x-ruby .rb .rbx<\/p>\n\n\n\n<p>Options Indexes FollowSymLinks ExecCGI<\/p>\n\n\n\n<p>LoadModule mime_module libexec\/apache2\/mod_mime.so<\/p>\n\n\n\n<p>systemctl restart apache2<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ruby Install guide stage 1: To install Ruby on Ubuntu and configure it with Apache, you&#8217;ll first need to install Ruby and its dependencies, then configure Apache to use Ruby&#8217;s mod_ruby or a suitable alternative like mod_passenger. You can achieve this by using the APT package manager or a version manager like Rbenv. Using APT. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-73","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/abmservermanagement.com.au\/index.php\/wp-json\/wp\/v2\/posts\/73","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/abmservermanagement.com.au\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/abmservermanagement.com.au\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/abmservermanagement.com.au\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/abmservermanagement.com.au\/index.php\/wp-json\/wp\/v2\/comments?post=73"}],"version-history":[{"count":1,"href":"http:\/\/abmservermanagement.com.au\/index.php\/wp-json\/wp\/v2\/posts\/73\/revisions"}],"predecessor-version":[{"id":74,"href":"http:\/\/abmservermanagement.com.au\/index.php\/wp-json\/wp\/v2\/posts\/73\/revisions\/74"}],"wp:attachment":[{"href":"http:\/\/abmservermanagement.com.au\/index.php\/wp-json\/wp\/v2\/media?parent=73"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/abmservermanagement.com.au\/index.php\/wp-json\/wp\/v2\/categories?post=73"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/abmservermanagement.com.au\/index.php\/wp-json\/wp\/v2\/tags?post=73"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}