
Deploying to Linux VM
I was exploring some open source chat applications which can be integrated with a website or can be useful in running an helpdesk. And I stumble upon Chatwoot, it's an open source project and by default, supports self-hosted installations so that you can own your customer data and be compliant with the regulations.
This guide will help you to install Chatwoot on Ubuntu 20.04 LTS / 20.10. There is a ready to use script for you to run. Refer to the script and feel free to make changes accordingly to OS if you are on on non-Ubuntu system.
Steps to install
Note: If you plan to use a domain with Chatwoot, please add an A record before proceeding. Refer the configuring the installation domain section below.
Create a setup.sh file and copy the content from the above link or use the following commands.
wget https://raw.githubusercontent.com/chatwoot/chatwoot/master/deployment/setup_20.04.sh -O setup.sh
chmod 755 setup.sh
Execute the script, and it will take care of the initial Chatwoot setup.
./setup.sh master
Chatwoot installation will now be accessible at
https://{your_ip_address}:3000
or if you opted for domain setup, it will be at https://chatwoot.mydomain.com.
Note: If you are running the script on Ubuntu VM on AWS EC2, make sure that you are logged in as root user not as the ubuntu user.
Configuring the installation domain
Create an
A
record forchatwoot.mydomain.com
on your domain management system and point it towards the installation IP address.Continue with the installation script by entering
yes
when prompted about domain setup.Enter your domain, and the script will take care of configuring Nginx and SSL via LetsEncrypt.
Your Chatwoot installation should be accessible from
https://chatwoot.mydomain.com
now.
Configure the required environment variables
For your Chatwoot installation to properly function, you would need to configure the essential environment variables like FRONTEND_URL
, Mailer and a clod storage config, Refer Environment variables for the full list.
Login as Chatwoot and edit the .env file.
# Login as chatwoot user
sudo -i -u chatwoot
cd chatwoot
nano .env
Refer Environment variables and update the required variables. Save the
.env
file.Restart the Chatwoot server and enjoy using your self hosted Chatwoot.
systemctl restart chatwoot.target
Upgrading to a newer version of Chatwoot
Whenever a new version of Chatwoot is released, use the following steps to upgrade your instance.
Run the following steps on your VM. Make changes based on your OS if you are on a non-Ubuntu system.
# Login as Chatwoot user
sudo -i -u chatwoot
# Navigate to the Chatwoot directory
cd chatwoot
# Pull the latest version of the master branch
git checkout master && git pull
# Ensure the ruby version is upto date
rvm install "ruby-3.0.2"
rvm use 3.0.2 --default
# Update dependencies
bundle
yarn
# Recompile the assets
rake assets:precompile RAILS_ENV=production
# Migrate the database schema
RAILS_ENV=production bundle exec rake db:migrate
# Switch back to root user
exit
# Copy the updated targets
cp /home/chatwoot/chatwoot/deployment/chatwoot-web.1.service /etc/systemd/system/chatwoot-web.1.service
cp /home/chatwoot/chatwoot/deployment/chatwoot-worker.1.service /etc/systemd/system/chatwoot-worker.1.service
cp /home/chatwoot/chatwoot/deployment/chatwoot.target /etc/systemd/system/chatwoot.target
# Restart the chatwoot server
systemctl restart chatwoot.target
If precompile fails
If the asset precompilation step fails with ActionView::Template::Error (Webpacker can't find application.css in /home/chatwoot/chatwoot/public/packs/manifest.json)
or if you face issues while restarting the server, try the following command and restart the server.
RAILS_ENV=production rake assets:clean assets:clobber assets:precompile
This command would clear the existing compiled assets and would recompile all the assets.
Running Rails Console
# Login as Chatwoot user
sudo -i -u chatwoot
# Navigate to the Chatwoot directory
cd chatwoot
# start rails console
RAILS_ENV=production bundle exec rails c
Viewing Logs
Run the following commands in your ubuntu shell.
# logs from the rails server
journalctl -u chatwoot-web.1.service -f
# logs from sidekiq
journalctl -u chatwoot-worker.1.service -f
Write a comment ...