Self-Hosting
Learn how to deploy erxes on your own server with detailed instructions for Ubuntu/CentOS, including server requirements and configuration.
System Requirements
- RAM: Ensure your environment has at least 2GB of RAM. Insufficient memory can cause processes to crash.
- Disk Space: Ensure you have at least 10GB of free disk space.
- Operating System: Ubuntu or CentOS
Prerequisites
Steps
Create an erxes user on the instance
Assuming you have connected to your instance and ready to execute following steps. First you need to create erxes user because all erxes related installation scripts are made for erxes user.
Why?
You don't want to use root user to administer your server. So everything will be done by a user called, erxes. To accomplish this, run the following command:
When prompted, enter unique & strong password. (Finish adding the user simply by pressing the enter or return key through the questions) Grant sudo and docker rights to erxes user by following command:
Create a directory for erxes
Place yourself in erxes directory
Initiate docker swarm mode
Now you need to initiate docker swarm mode in order to do that use following command.
Initiate docker swarm mode
Note
If you get a permission denied warning when you run this command, you haven't run the usermod -aG docker erxes command.
Note
In erxes directory we have docker-compose.yml file even with that we do not use docker-compose up, docker-compose down, docker-compose restart commands further
Setup and start the databases
Setup mongo key and certificate for replica set
Create mongodata directory
Create redisdata directory
Generate docker-compose-dbs.yml file
Copy the generated docker-compose-dbs.yml file to the erxes directory
Start the databases
Check the status of the databases
To check database services up use following command it will shows you all the running docker services id, name and state etc.
Make mongo have a replica set
Now we need to make our mongo have a replica set. First we need to enter the mongo container then enter the mongo instance then execute the 3 following commands.
Note
You may want to hit return or enter button a few times, if we have done it correctly mongo shell will changes into "RS0: primary"
To quit mongo instance and container run exit command twice.
Generate docker-compose.yml file
Now we need to generate docker-compose.yml file.
Copy the generated docker-compose.yml file to the erxes directory
Note
If you are using plugin and you need to add environment variables to the docker-compose.yml file, you can add them in the docker-compose.yml file.
Start the erxes
Check the status of the erxes
Check the status of the erxes
To check erxes services up use following command it will shows you all the running docker services id, name and state etc.
Configure the nginx
Now we need to configure the erxes.
Create a new nginx configuration file
Copy the nginx configuration file below
Note
Replace example.com with your domain name.
Test the nginx configuration
After that we need to test the nginx config. To do that use following command.
Restart the nginx
If nginx test shows successful message we need to restart Nginx. To do that use the following command.
Setup SSL certificate
erxes only works in secure connection to generate free ssl certificate we use Certbot. To configure that use the following command.
Note
You have to point your domain's A record to your erxes host machine in order to get certificate without that certbot will not generate certificate order.
Open the browser and enjoy our product
After entering this command, provide your email and subscription information, and accept the terms. Following that, you will be prompted about the 'redirect' option. We highly recommend enabling this option for security reasons. Once these steps are completed, open your browser and enjoy our product.
Removing erxes
Check the status of the erxes
First, it is unfortunate, but every server needs to be kept tidy. The following commands will help remove the Docker stack and any dangling containers in the swarm.
Remove the erxes docker stack
To remove the erxes docker stack, use the following command.
To remove all dangling containers use the following commands.
List and remove all dangling images.
List and remove all dangling containers.
List and remove all dangling volumes
List and remove all dangling networks