# Guide to Install investra on Linux

This guide will help you to install investra on your Linux machine. investra has a backend which is built using Laravel. The backend handles the database and API requests.

To install investra on your Linux machine, you will need to follow these steps:

1. Install Apache
2. Install MySQL
3. Install PHP
4. Install Composer
5. Install Our Admin Project
6. Configure Environment Variables
7. Start the Backend Server

## Prerequisites

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

- Apache
- MySQL
- PHP
- Composer

Please follow the below steps,

1. Extract the investra package that you download from CodeCanyon.
2. After that you see two zip files called 'core.zip', 'deployment.zip' and 2 folders local_deployment, documentation.
3. Now extract the core.zip file to the core folder.
4. now you'll get the `admin.zip` file on core folder.

As You can see the folder structure like below,

    investra
    ├── documentation
    ├── core
    │   └── admin.zip
    ├── local_deployment
    └── deployment.Zip

## Step 1: If you don't have Apache then Install Apache

1. Install Apache using the package manager for your Linux distribution. For example, on Ubuntu, you can install Apache using the following command:

    sudo apt-get update
    sudo apt-get install apache2

1. Start the Apache service and enable it to start on boot:

    sudo systemctl start apache2
    sudo systemctl enable apache2

1. Verify that Apache is running by visiting http://localhost/ in your web browser.

## Step 2: 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 and enable it to start on boot:

    sudo systemctl start mysql
    sudo systemctl enable mysql

1. (Optional) Secure your MySQL installation by running the following command:

    sudo mysql_secure_installation

1. Create a new MySQL database for your Laravel project:

1. Open a terminal window.
2. Run the following command to log in to MySQL:

    mysql -u root -p

1. Enter your MySQL root password when prompted.
2. Create a new database Laravel project:

    CREATE DATABASE investra_db;

1. Create a new user:

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

1. Grant the user all privileges on the database:

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

1. Flush the privileges to ensure that the changes take effect:

    FLUSH PRIVILEGES;

1. Exit the MySQL shell by running the following command:

    EXIT;

## Step 3: Install PHP

1. 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-exif php8.3-mysqli php8.3-pdo php8.3-zip -y

1. Restart the Apache service to apply the changes:

    sudo systemctl restart apache2

1. Verify that PHP is installed by creating a `phpinfo.php` file in the Apache web root directory:

    echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/phpinfo.php

1. Visit http://localhost/phpinfo.php in your web browser to view the PHP information.

## Step 4: Install Composer

1. Download and install Composer by running the following commands:

    php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
    php composer-setup.php
    php -r "unlink('composer-setup.php');"
    sudo mv composer.phar /usr/local/bin/composer

or

      sudo apt-get install composer

1. Verify that Composer is installed by running the following command:

    composer --version

## Step 5: Set Up Our Admin Project

1. Extract the project files to the directory then in this folder have 2 folder documentation and core folder. Now copy the core folder to the root folder.

Note: If you are a developer please follow the below steps to install our investra project. If you are not a developer please don't use the below steps, only follow GUI steps.

1. Navigate to the project directory and install the project dependencies using Composer:

    cd ~/Downloads/investra-project

1. Comment the below line on `/public/index.php` file:

     if (! file_exists(__DIR__.'/../storage/installed')) {
         header('Location: /installer/index.php');
         exit;
     }
    //  to

    // if (! file_exists(__DIR__.'/../storage/installed')) {
    //     header('Location: /installer/index.php');
    //     exit;
    // }

    composer install

1. Create a copy of the `.env.example` file and rename it to `.env`:

    cp .env.example .env

1. Generate an application key by running the following command:

    php artisan key:generate

1. Run the following command to migrate the database:

    php artisan migrate

1. Generate the application storage link by running the following command:

    php artisan storage:link

1. Generate dummy data for testing:

    php artisan db:seed

1. Start the Laravel development server:

    php artisan serve

1. Also start the npm server by running the following command:

    npm run dev

1. Open a web browser and navigate to http://localhost:8000 to view the Admin project.

## Conclusion

Congratulations! You have successfully installed investra on your Linux machine. You can now start customizing your application. If you have any questions, feel free to reach out to our support team. 🚀