Guide to Install Our investra on VPS

This guide will help you install our investra on VPS. If you have any questions, please contact our support team. With this tutorial, you can install investra to any type of blank or empty ubuntu server. For example, Digital Ocean Droplets, Amazon Lightsail, Google Cloud Virtual Private Server, Azure Ubuntu Virtual Private Server , etc. Please follow the documentation, and it'll make the installation process relatively easy.

Watch on YouTube

Prerequisites

Before you start, make sure you have the following installed on your VPS:

Installation Process

Step 1: Access VPS At first

you need to access your VPS. You can use SSH to access your VPS. If you don't have SSH, you can use any other method to access your VPS.

You can use ssh to access your VPS via Putty if you are windows user or use terminal if you are linux user.

ssh username@ipaddress
putty

then enter your password.

Step 2: Install Required Applications

  1. Install Zip & Unzip
sudo apt-get install zip unzip

Step 3: Setup Server

Nginx is one of the most popular web servers in the world. In this deployment tutorial, we're going to use Nginx to host our website. In this tutorial, we're going to use ubuntu 20.04 to host our website.

Step 3.1: Install Nginx

  1. Install Nginx using the package manager for your Linux distribution. For example, on Ubuntu, you can install Nginx using the following command:
sudo apt update
  1. Install Nginx using the package manager for your Linux distribution. For example, on Ubuntu, you can install Nginx using the following command:
sudo apt install nginx
  1. Verify that Nginx is installed by running the following command:
nginx -v
  1. Start Nginx by running the following command:
sudo systemctl start nginx

Step 3.2: Add PPA to get the specific php version

sudo add-apt-repository ppa:ondrej/php
sudo apt update

Step 3.3: Adjusting the Firewall

Before testing Nginx, the firewall software needs to be adjusted to allow access to the service. Nginx registers itself as a service with ufw upon installation, making it straightforward to allow Nginx access.

To check the ufw list, use this command,

sudo ufw status
sudo ufw app list

You will get a listing of an application list like this,

ufw

At first, add ssh to the firewall,

sudo ufw allow ssh
sudo ufw allow OpenSSH

After that, to enable Nginx on the firewall, use this command,

sudo ufw allow 'Nginx Full'

Now enable the firewall,

sudo ufw enable
sudo ufw default deny

You can verify the change by typing:

sudo ufw status

Step 4: Install MySQL

  1. Install MySQL using the package manager for your Linux distribution. For example, on Ubuntu, you can install MySQL using the following command:
sudo apt-get install mysql-server
  1. Start the MySQL service by running the following command:
sudo systemctl start mysql
  1. Verify the installation by running the following command:
mysql --version
  1. Secure your MySQL installation by running the following command:
sudo mysql_secure_installation
  1. Follow the on-screen instructions to secure your MySQL installation.

Step 5: Install PHP

Install PHP and the required PHP extensions using the package manager for your Linux distribution. For example, on Ubuntu, you can install PHP using the following command:

sudo apt install php8.3 php8.3-curl php8.3-fileinfo php8.3-gd php8.3-bcmath php8.3-gettext php8.3-mbstring php8.3-bcmath php8.3-exif php8.3-mysqli php8.3-pdo php8.3-zip php8.3-xml -y

Note: If you getting any error then use this command,

sudo apt update
sudo apt install -y software-properties-common ca-certificates lsb-release apt-transport-https

Add Ondřej Surý's PHP PPA

sudo add-apt-repository ppa:ondrej/php -y
sudo apt update

Again install all the required PHP extensions,

sudo apt install -y \
php8.3 php8.3-cli php8.3-common php8.3-mysql php8.3-zip php8.3-gd php8.3-mbstring \
php8.3-curl php8.3-xml php8.3-bcmath php8.3-intl php8.3-readline php8.3-soap

Now Install PHP FPM,

sudo apt install php8.3-fpm -y

Enable PHP FPM,

sudo systemctl enable php8.3-fpm

Step 6: Install Composer

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'.PHP_EOL; } else { echo 'Installer corrupt'.PHP_EOL; unlink('composer-setup.php'); exit(1); }"
php composer-setup.php
php -r "unlink('composer-setup.php');"
sudo mv composer.phar /usr/bin/composer

Or

sudo apt-get install composer

Step 7: Create MySQL Database & User

mysql -u root -p

Now, run the following command to create a database and user for investra. Make sure to replace investra_db, investra_user, and investra with your desired database name, username, and password, respectively.


CREATE DATABASE investra_db;

CREATE USER 'investra_user'@'localhost' IDENTIFIED BY 'investra_password';

GRANT ALL PRIVILEGES ON investra_db.* TO 'investra_user'@'localhost';

FLUSH PRIVILEGES;

exit
Warning

Note: This mysql credentials you need to save for GUI Admin Installer to work.

Step 8: Change permission for the www folder

cd  /var/www
sudo chown -R $USER:$USER /var/www

Step 9: Upload the Files

At first, use this command to create an admin directory on /var/www/

sudo rm -rf /var/www/investra
sudo mkdir /var/www/investra
sudo mkdir /var/www/investra/admin

Now, give the permission to the admin directory,

sudo chown -R www-data:www-data /var/www/investra/admin
sudo chmod -R 755 /var/www/investra/admin

Now upload the files to the directory,

  1. Extract the investra package that you download from CodeCanyon.
  2. On that folder, you'll get another file called core.zip.
  3. Now extract the core.zip file to the core folder.
  4. now you'll get the admin.zip file on core folder.

Now upload this files to the server,

Upload the admin.zip file to the /var/www/investra/admin directory,

scp -r core/admin.zip  root@server:/var/www/investra/admin

Now, extract the admin.zip file,

cd /var/www/investra/admin
unzip admin.zip -d /var/www/investra/admin
rm -rf admin.zip

Give permission to the admin folder,

sudo chown -R www-data:www-data /var/www/investra/admin/bootstrap/cache
sudo chown -R www-data:www-data /var/www/investra/admin/storage

Step 10: Get your Domain Name

Now we need to get a domain name for your admin panel.

We recommend to use a subdomain like app.example.com for the admin panel.

Step 11: Setting Up Server & Project

In this section, we'll set up our server and also will set up Reverse Proxy to host our site.

At first, we'll disable the default configuration of Nginx,

sudo rm /etc/nginx/sites-enabled/default

Now, we'll create a new admin configuration file,

sudo touch /etc/nginx/sites-available/investra-admin.conf
sudo nano /etc/nginx/sites-available/investra-admin.conf

Add this Nginx config file to that edited file,

server {
    listen 80;
    server_name app.YOUR_ADMIN_DOMAIN.com www.YOUR_ADMIN_DOMAIN.com;

    root /var/www/investra/admin/public;
    index index.php index.html;
    charset utf-8;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass unix:/run/php/php8.3-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
    }

    error_page 404 /index.php;

    location ~ /\.(?!well-known).* {
        deny all;
    }
}

Make sure you change YOUR_ADMIN_DOMAIN.com to your specific domain name You can change admin path, if you want to change the the domain path for the investra application

Save and close the file by typing CTRL and X, then Y and ENTER when you are finished.

Then enable the config

sudo ln -s /etc/nginx/sites-available/investra-admin.conf /etc/nginx/sites-enabled/investra-admin.conf

Step 12: Secure Server

sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d YOUR_ADMIN_DOMAIN.com -d www.YOUR_ADMIN_DOMAIN.com

Step 13: Restart Nginx

Make sure you didn't introduce any syntax errors by typing:

sudo nginx -t

Now, restart the Nginx service and PHP-FPM service,

sudo systemctl restart php8.3-fpm
sudo systemctl restart nginx
sudo ufw status
sudo ufw allow 'Nginx Full'
sudo ufw delete allow 'Nginx HTTP'
sudo ufw status

Step 14: Graphical User Interface (GUI) Installation

  1. Now access you domain name on your browser, then you can see the graphical user interface for the installation.
cpanelUpload9
  1. Agree with the terms and conditions and click "I Agree, Next Step" button.
  1. Now you can see the server requirements. If all the requirements are met then click "Next Step" button.
cpanelUpload10
  1. Now check all the required folder permissions is met then click "Next Step" button.
cpanelUpload11
  1. You see the configuration page and fill the required information.
Database Information
Admin Information
  1. Now hit "Install" button.
cpanelUpload12
  1. Now you will see the installation is completed. You can now access your investra on your domain name.

Step 15: Queue and Cron Job setup to this vps

To run the cron job, you need to add a cron job with the following command:

Step 1: install supervisor

sudo apt update
sudo apt install supervisor

Step 2: now create supervisor config file

sudo nano /etc/supervisor/conf.d/investra-worker.conf

Step 3: Add the following content to the file

[program:investra-worker]
process_name=%(program_name)s_%(process_num)02d
command=/usr/bin/php /var/www/investra/admin/artisan queue:work --sleep=3 --tries=3 --timeout=60
autostart=true
autorestart=true
user=your_linux_user
numprocs=1
redirect_stderr=true
stdout_logfile=/var/www/investra/admin/storage/logs/investra-worker.log

Note: Replace your_linux_user with your Linux user, and your_project_path with the path to your project on your VPS.

Step 4: restart supervisor

sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start investra-worker:*

Check the status:

sudo supervisorctl status

Step 5: Run the cron job on vps

Enable the cron tab

crontab -e

select your favorite editor, then add the following line at the end of the file

Enter the following command to run the cron job on vps

* * * * * cd /var/www/investra/admin && php artisan schedule:run >> /dev/null 2>&1

Note: Replace /var/www/investra/admin with the path to your project on your VPS Admin Project.

Step 6: Add the cron job to the crontab

crontab -l

Conclusion

Congratulations! You have successfully installed our investra on your VPS. If you have any questions, please contact our support team.