Skip to content

Installation Process

Required Credentials

  • Pusher Credentials for live data Get Pusher Credential (Required when BROADCAST_DRIVER is pusher)
  • SMTP Mail Server Credentials Mailgun
  • Database Credentials
  • Redis Server Credentials

Trademen is made on Laravel and the installation system is same as Laravel. See Laravel Installation Guide

Note: Before installing Trademen make sure all required software and PHP extensions are installed properly.

Installing Trademen

Trademen utilizes Composer to manage its dependencies. So, before using Trademen, make sure you have Composer installed on your machine. To check you have correctly installed composer run composer --version to your server terminal.

If you are not install composer yet then run sudo apt install -y composer to install composer.

Unzip Trademen project and put it into your server directory (For linux the server directory is /var/www/html). After this go to your project directory and run composer install to download all the dependency.

Directory Permissions

After composer install, you may need to give some directory permissions. Directories within the storage ,bootstrap/cache and resources/lang directories should be writable by your web server or Trademen will not run.

Example (for ubuntu. may vary for other linux distributions):

sudo chown -R www-data:www-data bootstrap/cache
sudo chown -R www-data:www-data storage
sudo chown -R www-data:www-data resources/lang

Nginx Configuration

The default nginx configuration is not suitable for Trademen. So you need to configure it. Open /etc/nginx/sites-available/default file with your favorite editor. Here we use vim. If vim is not install then run sudo apt install vim command or use vi instead of vim.

To open run the following command:

sudo vim /etc/nginx/sites-available/default

Remove all from that file and copy & paste the following configuration.

server {
    listen 80 default_server;
    server_name _;
    root /var/www/html/public;

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

    index index.php;

    charset utf-8;

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

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }

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

Save it and run nginx -t to check the configuration is correctly configured. If everythins id ok then restart the nginx server. To restart the server run the following command:

sudo service nginx restart

Environment Setup

The next thing you should do is renaming the .env.example file to .env, After that you need to configure it.

Generate Application Key

Set your application key to a random string. Typically, this string should be 32 characters long. If the application key is not set, your user sessions and other encrypted data will not be secure! Follow the command below to generate the key

php artisan key:generate

Open .env file via your favorite text editor and configure it

APP_NAME="My App"                       # Your own exchange name
APP_ENV=local                           # Change it to production once installation is done
APP_KEY=                                # This will be generated by the command given above
APP_DEBUG=true                          # Must be false in production mode
APP_PROTOCOL=http                       # Which protocol you are using
APP_URL=http://trademen.test            # Your Web Url
APP_INSTALLED=false                     # If don't want to install it vai web insteller then set it true
APP_TIMEZONE=UTC                        # Set it to 'UTC' or any timezone you prefer

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead                   # Your database name
DB_USERNAME=homestead                   # Your mysql username
DB_PASSWORD=secret                      # Your mysql password

CACHE_DRIVER=file                       # Supported cache driver: file, redis
QUEUE_CONNECTION=redis                  # Supported queue driver: redis
SESSION_DRIVER=file                     # Your session driver
SESSION_LIFETIME=120                    # Session life time in minute 

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

# Your Email Configuration

MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=
MAIL_FROM_ADDRESS=                      # The sender email address
MAIL_FROM_NAME=                         # The sender name

BROADCAST_DRIVER=redis
MIX_BROADCAST_DRIVER="${BROADCAST_DRIVER}"
MIX_BROADCAST_PORT=6001                         #Laravel Echo Server Port

# If you are using Laravel Echo Server then you can skip the pusher configuration  

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

NOCAPTCHA_SECRET=secret-key
NOCAPTCHA_SITEKEY=site-key
Database Migration

To make your mysql database ready you need to run following command. Before run this command make sure you have create the database and set it name in the .env file

php artisan migrate
Install initial Data

To push initial data in database, run the following command.

php artisan db:seed

Note: The website won't run without initial data.

To refresh the initial data in database after changing the seeders, run the following command (do not do it once you go live)

php artisan migrate:fresh --seed

Superadmin User Creation

To create superadmin user you need to run the following command. This command will ask some user info.

php artisan make:superadmin

To make them accessible from the web, you should create a symbolic link from public/storage to storage/app/public.

To create the symbolic link, you may use the storage:link command.

php artisan storage:link

Note: This command will help you to visible your media files in your system.

Test Data Seeding

Note: Don't do run it on the production server. It is for testing purpose

To run test data seed, first you need to configure Horizon. Otherwise it will throw an error.

If you want to test you system with some test data you may run the following command it will add some test data for you. It may take sometimes to execute, wait for it until it finished.

php artisan db:seed --class=TestSeeder

Remove Trademen Dev Dependencies

To remove Trademen dev dependencies run the following command. This will remove all packages that are not necessary in production.

composer install --optimize-autoloader --no-dev

Installing JavaScript Dependencies

NPM offers an option which allows to only install app dependencies required for production environment. Use one of the following commands to skip the devDependencies in your package.json

npm install --production

Run the following command to build and minify the JavaScript files.

npm run production