⚡ Read this only if you are hosting the Promptchat Server on your own VPS or Dedicated Server ⚡
Requirements
- docker
- docker-compose
- git
Installation
Written for Ubuntu, for other OS some commands may be different
1. Install docker engine https://docs.docker.com/engine/install/ubuntu/
2. Install docker-compose https://docs.docker.com/compose/install/other/
sudo chmod +x /usr/local/bin/docker-compose
Check docker-compose -v
If there is no error - go further, if there is - go to the last section of this article "possible problems solution”.
3. Check nginx
nginx -v
4. Send create a domain name domain_name
to the ip-address of the server where the project is deployed.
In the usual case, this means creating an A-record.
Creation instructions differ for many registrars, for example in the case of the GoDaddy registrar:
https://uk.godaddy.com/help/add-an-a-record-19238
5. Creating a User to deploy a Project
useradd user_name
6. Add the created user to the docker group
usermod -aG docker user_name
7. Log in as a user and run the commands to copy the project, replacing "user_name
" with your own value:
su - user_name
git clone https://github.com/promptchat/chatbot.git promptchat
cd /home/user_name/promptchat
8. Edit the file and replace the values of the variables with your own.
cp /home/user_name/promptchat/variables.env.example /home/user_name/promptchat/variables.env
edit /home/user_name/promptchat/variables.env
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
The APP_URL
variable must match the domain name (fqdn)
of the project.
If you plan to use your own database, you should write other variables that can be clarified in another section, which may someday be written.
9. Copy the license file to /home/user_name/promptchat/license.txt
10. Run
bash run.sh
11. Check (substitute your value instead of PORT
)
curl -IL http://localhost:PORT
If the answer is 200 - you can go further, if NOT 200 - to the section below
12. For nginx
create a configuration file (domain_name
must match APP_URL
, replace PORT
with your value from variables.env
)
edit /etc/nginx/conf.d/domain_name.conf
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;
}
}
13. Restart nginx
and check the result
curl -IL http://domain_name
14. In case the answer is 200 - add ssl-certificates.
For a free certificate:
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
⚡ Solutions to possible problems ⚡
1.
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
In this case, execute
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
2.
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.
Should there be errors, fix them.
Check logs of running containers docker logs CONTAINER_ID
for errors.
Check variables in variables.env
in case of variable change run bash down-rmi.sh && bash run.sh
3.
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
4.
In case curl localhost returns 500, one of the options:
down-rmi.sh
sudo -H -u user_name bash run.sh