- Navigate to the Digital Ocean dashboard and choose the appropriate project from the left menu.
- Click on Create > Droplets to initiate the setup process.
- Under Choose an Image, select Marketplace and then opt for the Ruby On Rails image. Ensure it's the appropriate version (e.g., Version 7.0.4.2, OS Ubuntu 22.04).
- For authentication, choose the SSH Key option and select your preferred SSH key.
- Click Create Droplet and patiently wait for the droplet to be provisioned.
- You can find more details about the package on the Ruby on Rails Droplet page.
Once the droplet is ready, access it via SSH using the following command:
ssh root@your_droplet_ip
Replace your_droplet_ip
with the actual IP address of your newly created droplet.
Install Redis on the server by following the Digital Ocean guide How To Install and Secure Redis on Ubuntu 20.04. Here are the summarized steps:
- Install Redis package. Run
apt install redis-server
. - Update Redis configuration. Edit
/etc/redis/redis.conf
and set thesupervised
directive tosystemd
. - Restart Redis service. Run
systemctl restart redis.service
to apply the changes.
- In the SSH console, sign in as the predefined rails user:
su - rails
- Clone Zax repository, navigate into the directory and run the script to install dependencies:
git clone https://github.com/vault12/zax.git
cd zax
./install_dependencies.sh
- Whitelist your hostname for production use
By default, Rails 6 applications reject all requests that are not made to the configured host. So you need to uncomment and modify line 11 in the production configuration file config/environments/production.rb
, uncomment the following line and insert your own URL to allow access to the app from your host:
config.hosts << "zax.example.com" # use your host name
- Disable Zax Dashboard to serve as frontend (optional)
If you want to disable access to the Zax Dashboard which provides a convenient UI, set the public_file_server
variable on line 64 in the production configuration file (config/environments/production.rb
) to false
. This action will prevent the Ruby server from serving files from the public/
directory.
config.public_file_server.enabled = false
- Exit from the rails user session by entering
exit
.
- Open
/etc/systemd/system/rails.service
and update theWorkingDirectory
andExecStart
directives as follows:
WorkingDirectory=/home/rails/zax/
ExecStart=/bin/bash -lc 'rails s --binding=localhost --environment production'
Save the changes and exit the editor.
To configure DNS for your domain, log in to your domain registrar's website and access the DNS management section. Add an A record by specifying your domain name and your droplet's IP address. Save the changes and wait for DNS propagation, which may take some time.
-
Edit the Nginx configuration file. In
/etc/nginx/sites-available/rails
), replaceserver_name _;
with the correct host name (e.g.server_name zax.example.com;
). -
Secure Nginx with Let's Encrypt. Follow the instructions in the Digital Ocean tutorial How To Secure Nginx with Let's Encrypt on Ubuntu 20.04 to obtain and install SSL/TLS certificates for your domain. Here are the summarized steps:
- Allow
Nginx Full
through the firewall and delete the rule forNginx HTTP
:
ufw allow 'Nginx Full'
ufw delete allow 'Nginx HTTP'
- Obtain SSL certificate using Certbot with Nginx plugin:
certbot --nginx -d zax.example.com
- Reload the systemd daemon and restart the Rails service to apply the changes:
systemctl daemon-reload
systemctl restart rails.service
Open https://zax.example.com in your browser to ensure Zax Dashboard is served over HTTPS.