Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Required package

Update the Ubuntu repository and install common packages:

Code Block
$ sudo apt-get update
$ sudesudo apt-get install curl
$ sudo apt-get install git
$ sudo apt-get install unzip
$ sudo apt-get install mbstring

Install PHP7.4

It’s crucial to install 7.4, not 8.x

Code Block
$ sudo add-apt-repository ppa:ondrej/php  
$ sudo apt-get update
$ sudo apt-get install php7.4
$ sudo apt-get install php7.4-fpm php7.4-pgsql php7.4-curl php7.4-cli php7.4-mbstring php7.4-xml

Make sure that curl, pgsql and pdo_pgsql extensions are installed

...

Info

In case of any problems, try to remove php-common and repeat the installation of modules

$ sudo apt-get --purge remove php-common

Install composer

Code Block
$ sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
$ sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer

Install postgres

Code Block
$ sudo apt-get install postgrespostgresql

Configuring the database

Code Block
$ sudo -u postgres psql -c "create database webclient;"
$ sudo -u postgres psql -c "create user webclient;"
$ sudo -u postgres psql -c "alter user webclient with encrypted password 'webclient';"
$ sudo -u postgres psql -c "grant all privileges on database webclient to webclient;"

For Postgres 15 and newer here are additional steps:

Code Block
GRANT ALL PRIVILEGES ON DATABASE webclient TO webclient;
\c webclient postgres
# You are now connected to database "webclient" as user "postgres".
GRANT ALL ON SCHEMA public TO webclient;

Install nginx

Code Block
$ sudo apt-get install nginx

Insert or change the location section of the Make sure you have the following in your ngnix.conf file

Code Block
index index.php index.html index.htm

location / {

        set $a "";
        if ($uri = "/") {
                set $a 1;
        }
        if (-f /var/www/html/init/index.php) {
                set $a 1$a;
        }
        if (!-f /var/www/html/api/conf.d/config.php) {
                set $a 1$a;
        }
        if ($a = 111) {
                rewrite ^(.*)$ /init/index.php last;
        }
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ =404;
}

location = /api/conf.d/admin_channel.json {
		deny all;
		return 404;
	}

location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php7.4-fpm.sock;
  }

Disable apache

Code Block
$ sudo systemctl stop apache2
$ sudo systemctl disable apache2

Restart ngnix

Code Block
$ sudo systemctl restart nginx

Copy and prepare the code

Copy Clone the Web Client package from GitHub to /var/www/html

Go to /api folder and run composer

Code Block
$ sudo composer install

Prepare 3 config files and copy them to /api/conf.d folder:

  1. firebase.php

  2. config.js

  3. config.php

Initialize the database

Open this URL in your browser window

http://your_server_ip:port/api/v1/db/update

It should show something like this in the browser:

...