Skip to content

Run from Source

Akram El Assas edited this page Jun 15, 2023 · 1 revision

Below are the instructions to run wexCommerce from code.

Prerequisites

Install git, Node.js, nginx on Linux or IIS on Windows, MongoDB and mongosh.

Configure MongoDB:

mongosh

Create admin user:

db = db.getSiblingDB('admin')
db.createUser({ user: "admin" , pwd: "PASSWORD", roles: ["userAdminAnyDatabase", "dbAdminAnyDatabase", "readWriteAnyDatabase"]})

Replace PASSWORD with a strong password.

Secure MongoDB by changing mongod.conf as follows:

net:
  port: 27017
  bindIp: 0.0.0.0

security:
  authorization: enabled

Restart MongoDB service.

Instructions

  1. Clone wexCommerce repo:
sudo git clone https://github.com/aelassas/wexcommerce.git
  1. Add api/.env file:
NODE_ENV = development
WC_PORT = 4004
WC_HTTPS = false
WC_PRIVATE_KEY = /etc/ssl/wexcommerce.key
WC_CERTIFICATE = /etc/ssl/wexcommerce.crt
WC_DB_HOST = 127.0.0.1
WC_DB_PORT = 27017
WC_DB_SSL = false
WC_DB_SSL_KEY = /etc/ssl/wexcommerce.key
WC_DB_SSL_CERT = /etc/ssl/wexcommerce.crt
WC_DB_SSL_CA = /etc/ssl/wexcommerce.ca.pem
WC_DB_DEBUG = true
WC_DB_APP_NAME = wexcommerce
WC_DB_AUTH_SOURCE = admin
WC_DB_USERNAME = admin
WC_DB_PASSWORD = PASSWORD
WC_DB_NAME = wexcommerce
WC_JWT_SECRET = PASSWORD
WC_JWT_EXPIRE_AT = 86400
WC_TOKEN_EXPIRE_AT = 86400
WC_SMTP_HOST = in-v3iljet.com
WC_SMTP_PORT = 587
WC_SMTP_USER = USER
WC_SMTP_PASS = PASSWORD
WC_SMTP_FROM = admin@wexcommerce.com
WC_ADMIN_EMAIL = admin@wexcommerce.com
WC_CDN_PRODUCTS = /var/www/cdn/wexcommerce/products
WC_CDN_TEMP_PRODUCTS =  /var/www/cdn/wexcommerce/temp/products
WC_BACKEND_HOST = http://localhost:8002/
WC_FRONTEND_HOST = http://localhost:8001/
WC_DEFAULT_LANGUAGE = en
WC_DEFAULT_CURRENCY = $

You must configure the following options:

WC_DB_PASSWORD
WC_SMTP_USER
WC_SMTP_PASS
WC_SMTP_FROM
WC_ADMIN_EMAIL
WC_BACKEND_HOST
WC_FRONTEND_HOST
  1. Add backend/.env file:
NEXT_PUBLIC_WC_API_HOST = http://localhost:4004
NEXT_PUBLIC_WC_PAGE_SIZE = 30
NEXT_PUBLIC_WC_CDN_PRODUCTS = http://localhost/cdn/wexcommerce/products
NEXT_PUBLIC_WC_CDN_TEMP_PRODUCTS = http://localhost/cdn/wexcommerce/temp/products
NEXT_PUBLIC_WC_APP_TYPE = backend

You must configure the following options:

NEXT_PUBLIC_WC_API_HOST
NEXT_PUBLIC_WC_CDN_PRODUCTS
NEXT_PUBLIC_WC_CDN_TEMP_PRODUCTS
  1. Add frontend/.env file:
NEXT_PUBLIC_WC_API_HOST = http://localhost:4004
NEXT_PUBLIC_WC_PAGE_SIZE = 30
NEXT_PUBLIC_WC_CDN_PRODUCTS = http://localhost/cdn/wexcommerce/products
NEXT_PUBLIC_WC_CDN_TEMP_PRODUCTS = http://localhost/cdn/wexcommerce/temp/products
NEXT_PUBLIC_WC_APP_TYPE = frontend

You must configure the following options:

NEXT_PUBLIC_WC_API_HOST
NEXT_PUBLIC_WC_CDN_PRODUCTS
NEXT_PUBLIC_WC_CDN_TEMP_PRODUCTS
  1. Configure http://localhost/cdn
  • On Windows, install IIS and create C:\inetpub\wwwroot\cdn folder.
  • On Linux, install Nginx and add cdn folder by changing /etc/nginx/sites-available/default as follows:
server {
    listen 80 default_server;
    server_name _;
    
    ...

    location /cdn {
      alias /var/www/cdn;
    }
}
  1. Create an admin user from http://localhost:8002/sign-up

You can change language and currency from settings page in the backend.