GuidesChangelogDiscussions
Log In

Step-by-Step Guide

Starting with a Fresh Debian Install

For this guide we will have created a brand new Digital Ocean Droplet with the basic VPS requirements of 1G ram, 1 CPU and 25GB of disk space. Ensure you have root SSH capabilities and login to your newly installed instance.

Debian Version 11 x64 Droplet

Droplet Configuration

Droplet Configuration

Upgrade Base Installation

Digital Ocean generally has gold images that may be a few subversions out of date, so first thing we need to do is upgrade our installation. Login as the root user for the following guide. We will be creating an application user during this process.

apt-get update && apt-get -y upgrade
apt-get -y dist-upgrade
reboot

Once your server has rebooted and you have reconnected as the root user. We will begin by adding the PHP 8.2 Repository.

Add Packages for PHP 8.2 from the sury.org Repo

# Install apt tools
apt-get -y install software-properties-common

# Add Repo for PHP 8.2
apt-get -y install apt-transport-https lsb-release ca-certificates wget
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg 
sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
apt-get update

Next we will install PHP, NGINX, MariaDB, Redis and a few other packages.

Install PHP, NGINX, MariaDB and Additional Libraries

apt-get -y install git redis-server nginx mariadb-server \
mariadb-client php8.2 php8.2-cli php8.2-fpm \
php8.2-gd php8.2-bcmath php8.2-curl php8.2-igbinary \
php8.2-mysql php8.2-opcache php8.2-phpdbg php8.2-readline \
php8.2-redis php8.2-xml php8.2-zip php-mbstring

Now that PHP is installed we will need to download Composer. Composer is an application that helps manage all of our application libraries, including Laravel and corresponding packages required for Logic to operate.

Add Logic Application User

Since we will not be running the application as root, we will need to create a new user for this application to run inside. Create a logic user, set the password from the prompt, and then press enter through the rest of the prompts

adduser logic

Install Composer

🚧

Install Composer from Official Website - DO NOT COPY BELOW

The command below may not work as versioning changes and is only shown below to give you an example of what it looks like.

Visit getcomposer.org/download and copy/paste the 4 lines provided. They will look like this:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

Move Composer to /usr/bin for Global Use

mv composer.phar /usr/bin/composer && chmod 755 /usr/bin/composer

Install NodeJS v16 and NPM

Logic requires nodejs and npm for webmix.

curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
apt-get -y install gcc g++ make nodejs

Install Certbot for SSL (optional)

If you would like to use LetsEncrypt for SSL, you can install certbot that will be used to generate SSL certificates and update NGINX.

apt-get -y install certbot python3-certbot-nginx

Create a MySQL Database

The following commands will create a database and set a password.

πŸ“˜

Create your Own Password

The password provided below is for example only. You should change this and not use the password in the example. While this is not a requirement, it's smart to do so.

mysql
create database logic;
GRANT all on logic.* to 'logic'@'localhost' IDENTIFIED by 'somepassword123!#@';
quit

Download Logic

We are now ready to download the project and run the installation commands.

cd /home/logic
su logic
git clone https://github.com/Vocalogic/logic
cd logic
composer install
npm install
cp .env.example .env
chmod 777 storage -R
chmod 777 bootstrap -R

Update the .env file with the following edits

You will need to update your .env file with the password you created as well as the URL that you are going to use for your logic installation.

🚧

Do not blindly copy/paste below

Please make sure that you use the password that you used to create your database and replace "mylogicsite" with the full domain that you will be using.

APP_URL="http://mylogicsite"

DB_DATABASE=logic
DB_USERNAME=logic
DB_PASSWORD="somepassword123!#@"

Upgrading to Latest Version and Migrations

After you have set your .env file properly with the right password, run the following commands to upgrade to the latest version and run all database migrations and seeders.

./artisan key:gen
./artisan logic:upgrade

Configuring the Scheduler

Logic performs different operations during different times of the day, for invoice generation and metrics gathering. To enable the scheduler while still acting as the user "logic" type:

crontab -e

If you are prompted to select an editor, you can use the editor of your choice. We will use nano for the guide, select 1.

Add the following line:

* * * * * cd /home/logic/logic; php artisan schedule:run > /dev/null 2>&1

Hit Ctrl-X , then Y then Enter

Setting up NGINX

First you will need to setup a DNS entry for your new site. If you have a domain for instance called mydomain.com and would like to setup Logic as customer.mydomain.com you will need to create an A Record in DNS and create the customer host and point the "A Record" to the IP of your server. For more information on how to setup DNS please refer to your hosting provider as it is outside the scope of this guide.

Start by removing the default site in nginx. Do this by typing

exit # If you are still sudo as 'logic'
cd /etc/nginx/sites-enabled
rm default

Now you need to create a new file called logic that will house the following. You can use nano, vim, whatever editor you wish to use. For this guide we will be using vim.

Type: vim logic and press enter. Paste the following in the file, edit your server name (the first line) with your domain name where Logic will be found. Then press ESC and then :x

πŸ“˜

Edit the server_name below

Replace install.logic.host below with your domain name where Logic will be found.

server {

    server_name install.logic.host;
    root /home/logic/logic/public;
    index index.php;
    access_log /var/log/nginx/logic.access.log;
    error_log /var/log/nginx/logic.error.log;
    charset utf-8;
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { log_not_found off; access_log off; }
    location = /robots.txt { log_not_found off; access_log off; }
    error_page 404 /index.php; 
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
    # Deny .htaccess file access
    location ~ /\.ht {
    deny all;
    }
}

After you have completed this step, restart nginx

/etc/init.d/nginx restart

You should now be able to browse to your URL and be prompted for the final installation step creating your new admin account. Visit http://yourdomain.com and complete the final fields.

πŸ“˜

Queue Worker and Jobs

By default, Logic will use Laravel's sync driver to offload jobs. This is not a good long term solution and redis and supervisord should be used to process jobs. See Queue Worker for more information on installation and configuration.


What’s Next