buy
How to setup Ruby with Application Manager

Requirements

Install ruby package from Webuzo Admin Panel.

In case ruby is not installed, ask your server admin to install it from Webuzo Admin Panel > Apps > Install an App

This will install the latest version of ruby.

Setup Ruby application

Execute the below commands from the user's terminal. Make sure you edit and replace the dummy user path and domain path with the correct ones before executing the below commands.

mkdir sample_ruby_app
cd sample_ruby_app

Create a file named server.rb and open it in any editor.

vi server.rb

Copy the below source code and paste it into server.rb file and save the file.

require 'webrick'

# Create a new server instance
server = WEBrick::HTTPServer.new(
  Port: 30000, # The port the server will listen on
  DocumentRoot: '.' # The root directory for serving files
)

# Define a simple response for the root URL
server.mount_proc '/' do |req, res|
  res.content_type = 'text/html'
  res.body = <<~HTML
    <!DOCTYPE html>
    <html>
    <head>
      <title>Sample Ruby Web App</title>
	   <style>
		  h1 {
			color: #333;
			text-align: center;
			margin-top: 50px;
		  }
		  p {
			font-size: 18px;
			line-height: 1.6;
			width: 60%;
			margin: 0 auto;
			text-align: justify;
		  }
		</style>
    </head>
    <body>
		<h1>My First App</h1>
		<p>Welcome to my first Ruby app! This is a simple page with a title and a paragraph of text. I've added some basic CSS styling to make the page look a little bit better. I hope you like it!</p>
    </body>
    </html>
  HTML
end

# Shut down the server gracefully on Ctrl+C
trap 'INT' do
  server.shutdown
end

# Start the server
server.start

To add ruby application go to Webuzo Enduser Panel > Applications > Add Applications

Note : Before adding the application change the port in your project as given in "Add application" wizard.

For example in this application add following lines in server.rb file inside server instance and change the port as given.

require 'webrick'

server = WEBrick::HTTPServer.new(
  Port: 30000,
  DocumentRoot: '.'
)

Fill the required fields, select ruby from "Application type" drop down and save it.

Enter the start command "/usr/local/apps/ruby/bin/ruby server.rb" .

ruby-sample-app

After saving it will be show in "List Applications" wizard.

ruby-list-app

After the adding application check the domain in browser

ruby-app-output
    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list