How to Install Chatwoot on NixOS Latest
Chatwoot is an open-source customer support and messaging tool that can be integrated into websites and applications. It is designed to provide businesses with a platform for handling customer interactions efficiently. In this tutorial, we will guide you step-by-step on how to install Chatwoot on the latest version of NixOS.
Prerequisites
Before you proceed with the installation of Chatwoot on NixOS, you need to ensure the following requirements are met:
- A server or virtual machine running the latest version of NixOS
- A non-root user with sudo privileges configured on your server
- Access to a terminal or SSH client
Step 1: Install Required Dependencies
Chatwoot is built with Ruby on Rails, and it requires several dependencies to be installed on your system. We need to run the following command to install them on your NixOS system:
$ sudo nix-env -i ruby rubyPackages.bundler postgresql
This will install Ruby, Bundler, and PostgreSQL packages required for Chatwoot.
Step 2: Install Git
To get the latest source code of Chatwoot, we need to install Git on our system. Run the following command to install Git:
$ sudo nix-env -i git
Step 3: Clone Chatwoot Repository
Now, we need to clone the Chatwoot repository using Git. Run the following command to clone the repository:
$ git clone https://github.com/chatwoot/chatwoot.git
This will clone the Chatwoot repository into your current directory.
Step 4: Install Chatwoot Dependencies
Navigate to the Chatwoot directory by running the following command:
$ cd chatwoot
Next, we need to install Chatwoot's dependencies. Run the following command to install it using Bundler:
$ bundle install
This will install all the required gems to run Chatwoot.
Step 5: Setup Database
Chatwoot uses PostgreSQL as its database management system. We need to create a new PostgreSQL user and database for Chatwoot. Run the following command to create a new PostgreSQL user:
$ sudo -u postgres createuser -s chatwoot_user
Next, create a new PostgreSQL database for Chatwoot using the following command:
$ sudo -u postgres createdb -O chatwoot_user chatwoot_production
Update the config/database.yml file with the PostgreSQL username and database details:
production:
database: chatwoot_production
adapter: postgresql
username: chatwoot_user
password: <%= ENV['DATABASE_PASSWORD'] %>
host: localhost
port: 5432
encoding: unicode
pool: 5
timeout: 5000
Note: Replace <%= ENV['DATABASE_PASSWORD'] %> with the password for your PostgreSQL user.
Step 6: Configure Backend Environment Variables
Create a .env file in the Chatwoot directory that contains the following environment variables:
# PostgreSQL database configuration
DATABASE_PASSWORD=<password>
# Mailer configuration
SMTP_ADDRESS=<smtp_host>
SMTP_PORT=<smtp_port>
SMTP_USERNAME=<smtp_username>
SMTP_PASSWORD=<smtp_password>
EMAIL_FROM_ADDRESS=<sender_email_address>
# Domain details
DOMAIN=<domain_name>
Note: Replace <password>, <smtp_host>, <smtp_port>, <smtp_username>, <smtp_password>, <sender_email_address>, and <domain_name> with your own configuration.
Step 7: Compile Assets
We need to compile assets before starting the Rails server. Run the following command to compile assets:
$ bundle exec rails assets:precompile RAILS_ENV=production
Step 8: Install Systemd Service
To start Chatwoot automatically on system boot, we will create a system service.
Create a new file /etc/systemd/system/chatwoot.service using a text editor:
$ sudo nano /etc/systemd/system/chatwoot.service
Add the following content to the file:
[Unit]
Description=Chatwoot backend application service
After=network.target
[Service]
Environment="RAILS_ENV=production"
WorkingDirectory=/path/to/chatwoot
ExecStart=/usr/bin/env bash -lc 'bundle exec rails server -e production'
Restart=on-failure
[Install]
WantedBy=multi-user.target
Note: Replace /path/to/chatwoot with the path to Chatwoot directory.
Save and close the file.
Step 9: Enable and Start Chatwoot Service
Reload the systemd daemon to read the new service file:
$ sudo systemctl daemon-reload
Enable the Chatwoot service to start at system boot:
$ sudo systemctl enable chatwoot
Start the Chatwoot service using the following command:
$ sudo systemctl start chatwoot
Step 10: Configure Firewall
We need to open the HTTP default port 3000 to allow external access to Chatwoot. Run the following command to open port 3000 on the firewall:
$ sudo firewall-cmd --zone=public --add-port=3000/tcp --permanent
Reload the firewall to apply the changes:
$ sudo firewall-cmd --reload
Step 11: Access Chatwoot
Open your web browser and access the Chatwoot application using your server's IP address or domain name followed by port number: http://[server-ip]:3000
Now, you can log in to Chatwoot using the default login details:
- Email:
[email protected] - Password:
password
Conclusion
By following this tutorial, you should have successfully installed a Chatwoot instance on the latest version of NixOS. You can now use Chatwoot to provide customer support and messaging features to your customers.