Skip to main content

Installation

⚡ Read this only if you are hosting the Promptchat Server on your own VPS or Dedicated Server ⚡

Requirements

  • VPS account (AWS, VULTR, Google Cloud etc.)
  • Allocated domain name
  • Access to DNS configuration

Installing VPS

Written for AWS Lightsail server instance

Preparations (AWS)

  • Sign in to your AWS account and choose a Lightsail server instance.

  • Select "Create Instance", then under "Linux / Unix", choose the "Operating System (OS only)"" option for Select a platform.

  • After selecting Ubuntu 22.04 LTS, choose the appropriate server size, e.g.:

    • 4 GB Memory
    • 2 vCPUs Processing
    • 80 GB SSD Storage
    • 4 TB Transfer

We will install the following OS runtime components

  • docker server
  • docker-compose
  • NGNIX

Docker Server installation

sudo apt update
sudo apt install ca-certificates curl gnupg lsb-release -y
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y

Check

If appears the message "Hello from Docker!" the installation was success!

sudo docker run hello-world

Docker Compose installation

sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

Check

docker-compose --version

NGINX installation

sudo apt update
sudo apt install nginx -y

Check

nginx -v

Create and configure a User to deploy

A new user will be created under "chatuser" name in this example but it can be any value. You will be prompted to enter the new user password.

sudo adduser chatuser
sudo usermod -aG docker chatuser

Log in as a user and run the commands to copy the Git repository

su - chatuser
git clone https://github.com/promptchat/chatbot.git promptchat
cd /home/chatuser/promptchat

Copy the file, then replace the values of the variables with your own.

Assuming you are already in the /home/chatuser/promptchat directory.

cp variables.env.example variables.env
nano variables.env

After entered the values, save the file: CTRL + O then close it: CTRTL + X

  • DB_PASSWORD must be complex, simple passwords cannot be used.

  • The PORT variable must be any free port.

You can check not free ports:

lsof -i -n -P

Copy the license file to project directory

Replace the /local/directory/license.txt path with your local path on your PC where you have downloaded the license file

cp /local/directory/license.txt /home/chatuser/promptchat/license.txt

Install the chatbot app

cd /home/chatuser/promptchat
bash run.sh

Check (substitute your value instead of PORT)

bash curl -IL http://localhost:PORT

If the answer is 200 - you can go further, if NOT 200 follow to the bugfixing section below

Configure NGINX

Create a configuration file. Replace the domain_name with yout own domain's name.

sudo nano /etc/nginx/conf.d/domain_name.conf

Enter the newly created file's content

domain_name must match APP_URL, replace PORT with your value from variables.env

server {
listen 80;
server_name domain_name;
location / {
proxy_pass http://localhost:PORT;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 86400;
proxy_ssl_server_name on;
}
}

Restart NGINX engine

sudo systemctl restart nginx

Check the application

curl -IL http://domain_name

In case the answer is 200 - add ssl-certificates if not, go to bugfixes section below.

Configure DNS settings

Sign in to your domain name provider’s control panel and open the DNS zone editor for your domain. Add a new record with the following details:

  • Name: your domain, e.g.: example.com
  • TTL: 3600
  • Type: A
  • Record: Your VPS IPv4 (IP) address
tip

Please note that DNS propagation can take up to 24 hours. Once the propagation is complete, the associated content will appear.

SSL

If necessary install free SSL certificate for the app

sudo apt install snapd
sudo snap install core; sudo snap refresh core
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo certbot --nginx

Bugfixes

⚡ Solutions to possible problems ⚡

  • If docker-compose is installed according to the instructions but the path is different, create a link
which docker-compose
  • The answer will be for example /usr/local/bin/docker-compose run
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

  • If after run.sh the test curl gives a response other than 200, you should:
    • Check the contents of /home/user_name/promptchat/sources/storage/logs/laravel-DATE.log for errors.
    • Check variables in variables.env in case of variable change run
    bash down-rmi.sh && bash run.sh

  • In case we see an error Access denied for user 'promptchat'@:
docker ps -a |grep mysql
docker inspect CONTAINER_ID |grep IPAddress
telnet IP_ADDRESS 3306
mysql -hIP_ADDRESS -upromptchat -p

  • In case curl localhost returns 500, one of the options:
down-rmi.sh
sudo -H -u chatuser bash run.sh