Evolution API can be easily installed using the Node Version Manager (NVM). Follow these steps to set up your environment and start the Evolution API on your server.
Next, navigate to the folder where the project is located.
Copy
cd evolution-apinpm install
Now, let’s copy the env.yml file with the settings you need to edit.
Copy
cp src/dev-env.yml src/env.ymlnano src/env.yml
This command creates a copy of the default environment file.Next, open the env.yml file in a text editor to enter your configuration settings. You can use nano, a command-line text editor, for this purpose:
Copy
nano src/env.yml
In the nano editor, navigate through the file and replace the default values with your specific settings. This can include database connection strings, API keys, server ports, etc.
Refer to the environment variables section for detailed instructions on how to set up your env.yml file.
To start the Evolution API, use the following command:
In the example above, it is assumed that your VPS has at least 4GB of RAM available exclusively for the Evolution API.Available memory may vary, we recommend at least 1GB to run Evolution.
If you want to ensure the API is running, simply use your browser to access http://localhost:8080. This should be the response from your browser:
http://localhost:8080/
Copy
{ "status": 200, "message": "Welcome to Evolution API, it is working!", "version": "1.x.x", "documentation": "http://localhost:8080/docs"}
EvolutionAPI has built-in Swagger endpoint documentation, which you can use to see all possible endpoints and test requests by accessing http://localhost:8080/docs.
Next, paste the Nginx configuration into the default.conf file:
/etc/nginx/conf.d/default.conf
Copy
server { listen 80; listen [::]:80; server_name _; root /var/www/html/; index index.php index.html index.htm index.nginx-debian.html;location / { try_files $uri $uri/ /index.php; }location ~ \.php$ { fastcgi_pass unix:/run/php/php7.4-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; include snippets/fastcgi-php.conf; }# Long browser cache time can speed up repeat visits to your pagelocation ~* \.(jpg|jpeg|gif|png|webp|svg|woff|woff2|ttf|css|js|ico|xml)$ { access_log off; log_not_found off; expires 360d; }# disable access to hidden fileslocation ~ /\.ht { access_log off; log_not_found off; deny all; }}
After making changes to the Nginx settings, it is essential to reload the Nginx service. This ensures that any modifications you have made are applied and become effective.Run the following command in the terminal to reload Nginx:
Copy
systemctl reload nginx
Make the nginx user the owner of the web directory, by default, it is owned by the root user:
Copy
chown www-data:www-data /usr/share/nginx/html -R
Now, create a Virtual Host pointing to your subdomain by editing the api file:
Copy
cd ~nano /etc/nginx/sites-available/api
Next, paste the Nginx configuration into the api file:
Next, validate the Nginx configuration for the subdomain:
Copy
nginx -t
This message should appear on your terminal if everything has been set up correctly:nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
You will be asked if you want to enter an email to receive notifications when the generated certificate is close to its expiration date.
If the certification is successful, at the end of the process, a line with the following message will be displayed:“Congratulations! You have successfully enabled HTTPS”