Rails

The OpenLiteSpeed Rails One-Click app automatically installs performance web server OpenLiteSpeed, Ruby and Rails. This image is still in beta! OpenLiteSpeed features easy setup for SSL and RewriteRules. OLS is flexible and also supports Python and NodeJS apps, as well as CMSs like WordPress.

Quick Start

Step 1.

Linode

Use the "OpenLiteSpeed Rails StackScripts" to create a server with any plan you want. Click here to create an account

Step 2.

An interactive script that runs will first prompt you for your domain or subdomain.

You can press CTRL+C and continue to SSH. The prompt will open again the next time you log in, and will continue to do so until you finish the whole setup.

Please input a valid domain:
Please verify it is correct. [y/N]

Tip

Enter the root domain only, then the system will add both the root domain and the www domain for you..

You can also automatically apply Let's Encrypt SSL if your domain is pointed to this server already. Enter y and your email address to finish the process.

Do you wish to issue a Let's encrypt certificate for this domain? [y/N]
Please enter your E-mail:
Please verify it is correct: [y/N]
Once finished, you should see Certificate has been successfully installed...

Do you wish to force HTTPS rewrite rule for this domain? [y/N]
Once finished, force HTTPS rules will be applied

Do you wish to update the system which include the web server? [Y/n]
This script will automatically go away after your domain has been added.

Step 3.

Visit the default script by entering http://Server_IP on your browser and you should see Yay! You’re on Rails! default page.

Start editing the Rails project here

/usr/local/lsws/Example/html/demo

Update system software.

sudo apt-get update && sudo apt-get upgrade -y

Your system is installed and ready to use!

Components

The OpenLiteSpeed Rails 1-Click Droplet installs several packages and performs other actions on your system.

Package Installation

Component Version
Linux Ubuntu 18.04.1
rbenv Latest from rbenv Repo
Ruby Latest from rbenv Repo
gem Latest from rubygem Repo
Bundler Latest from gem
Rails Latest from gem
OpenLiteSpeed Latest from LiteSpeedtech Repo
Node.js Latest from APT
NPM Latest from APT
Certbot Latest from Certbot’s PPA

Other Actions

  • Enables the UFW firewall to allow only SSH (port 22), HTTP (port 80) and HTTPS (port 443) access.

How to Access the Installed Software

From a terminal on your local computer, connect to the server as root, like so:

ssh root@use_your_server_ip

Be sure to substitute the server’s public IP address for use_your_server_ip.

Web Server Control Panel Access

Get the WebAdmin admin password:

cat .litespeed_password
cat /home/ubuntu/.litespeed_password
cat /home/ubuntu/.litespeed_password

Visit https://use_your_droplet_ip:7080 to access WebAdmin in a browser.

!wpapp 6

By default, WebAdmin uses port 7080. To allow access to 7080 from your IP(e.g. 1.2.3.4):

ufw allow from 1.2.3.4 to any port 7080
You can also allow all IPs access to port 7080:
ufw allow 7080
We suggest turning this port off once you've finished setup:
ufw delete allow 7080

Optional Setup

Enable HTTPS

Setting up an SSL certificate enables HTTPS on the web server, which secures the traffic between the server and the clients connecting to it. Certbot is a free and automated way to set up SSL certificates on a server.

Step 1. Register Domain

To use Certbot, you’ll need a registered domain name and DNS records:

  • An A record from the domain (e.g., example.com) to the server’s IP address

  • An A record from the domain prefaced with www (e.g., www.example.com) to the server’s IP address.

Step 2. Add Domain to Listener

Navigate to OpenLiteSpeed Web Server WebAdmin > Listeners, and add Your Domain to HTTP/HTTPS.

!listener 1

Step 3. Certbot

Once the DNS records are set up, you can generate the SSL certificate. Be sure to substitute the correct domain name in the following command:

certbot certonly --webroot -w /var/www/html/ -d example.com -d www.example.com
If certificate verification is a success, you should find your certificate files stored in /etc/letsencrypt/

Step 4. Set SSL for HTTPS

!wpapp 7

Navigate to OpenLiteSpeed Web Server WebAdmin > Listeners > SSL, and edit the following three items:

  • Private Key File = /etc/letsencrypt/live/example.com/privkey.pem
  • Certificate File = /etc/letsencrypt/live/example.com/fullchain.pem
  • Chained Certificate = Yes

Save and perform a Graceful Restart.

Now your server should support TLS1.1, TLS 1.2, and TLS 1.3.

Step 5. Redirect HTTP to HTTPS

!wpapp 8

HTTPS traffic on port 443 is already allowed through the firewall. After you set up HTTPS, you can optionally rewrite all HTTP traffic to HTTPS.

Add the following rules to OpenLiteSpeed Web Server WebAdmin > Virtual Hosts > Rewrite > Rewrite Rules

RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/$1 [R,L]

Method for Uploading Files

You can serve files from the web server by adding them to the web root using SFTP or other tools.

Frequently Asked Questions

How do I Reset my Web Server WebAdmin Password?

If you forget your password, you may run the following command to reset it:

/usr/local/lsws/admin/misc/admpass.sh

It will ask for the WebAdmin username, which should be admin. Then, enter your new password.

How do I Create Additional Virtual Hosts?

Auto Setup via Script

This method will automatically set up Listener/VirtualHost/Force SSL/Let's Encrypt/WordPress.

Interactive mode

wget https://raw.githubusercontent.com/litespeedtech/ls-cloud-image/master/Setup/vhsetup.sh
chmod +x vhsetup.sh
bash vhsetup.sh
Or just run the script without downloading it:
/bin/bash <( curl -sk https://raw.githubusercontent.com/litespeedtech/ls-cloud-image/master/Setup/vhsetup.sh )

CLI mode

wget https://raw.githubusercontent.com/litespeedtech/ls-cloud-image/master/Setup/vhsetup.sh
chmod +x vhsetup.sh
bash vhsetup.sh -d www.example.com -le admin@example.com -f -w
Or just run the script without downloading it:
/bin/bash <( curl -sk https://raw.githubusercontent.com/litespeedtech/ls-cloud-image/master/Setup/vhsetup.sh ) -d www.example.com -le admin@example.com -f -w

  • Please be sure that your domain is already pointing to the server when using -le YOUR_EMAIL

  • Please be sure that your environment has php/sql service/sql root password when using -w

Manual Setup

By default, OpenLiteSpeed has an example virtual host already created. You can create more virtual hosts if you like. See Create Virtual Hosts on OpenLiteSpeed.

How do I upgrade OpenLiteSpeed to latest stable version?

OpenLiteSpeed was installed from the LiteSpeed repository, so you can simply use the system update to update OpenLiteSpeed to the latest stable version.

$ sudo apt-get update && sudo apt-get upgrade openlitespeed -y

How do I Create Additional Apps by Context?


Last update: April 27, 2020