Linux Setup Guide

Complete installation and configuration guide for Linux distributions

Prerequisites

Before installing AsseTrack on Linux, ensure you have:

  • Ubuntu 18.04+ or CentOS 7+ or similar Linux distribution
  • Root or sudo privileges
  • At least 4GB of RAM (8GB recommended)
  • 2GB of free disk space
  • Internet connection for downloading packages
  • Basic knowledge of Linux command line

Step 1: Install Node.js

1

Update Package Lists

sudo apt update
2

Install Node.js 22

Add NodeSource repository and install Node.js:

# Add NodeSource repository
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
# Install Node.js
sudo apt-get install -y nodejs
3

Verify Installation

node --version npm --version
1

Install EPEL Repository

# For CentOS 7 sudo yum install -y epel-release # For CentOS 8/RHEL 8 sudo dnf install -y epel-release
2

Install Node.js

# For CentOS 7 sudo yum install -y nodejs npm # For CentOS 8/RHEL 8 sudo dnf install -y nodejs npm

Note

If the default version is too old, use NodeSource repository as shown in Ubuntu section.

1

Install Node.js

sudo pacman -S nodejs npm

Step 2: Install MySQL

1

Install MySQL Server

sudo apt install -y mysql-server
2

Secure MySQL Installation

sudo mysql_secure_installation

Follow the prompts to set root password and configure security options.

1

Install MySQL Server

# For CentOS 7 sudo yum install -y mysql-server # For CentOS 8/RHEL 8 sudo dnf install -y mysql-server
2

Start and Enable MySQL

# For CentOS 7 sudo systemctl start mysqld sudo systemctl enable mysqld # For CentOS 8/RHEL 8 sudo systemctl start mysqld sudo systemctl enable mysqld
1

Install MySQL

sudo pacman -S mysql
2

Initialize MySQL

sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
3

Create Database

# Login to MySQL
sudo mysql -u root -p # Create database
CREATE DATABASE assettrack_db; # Create user (optional but recommended)
CREATE USER 'assettrack'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON assettrack_db.* TO 'assettrack'@'localhost';
FLUSH PRIVILEGES; EXIT;

Step 3: Install AsseTrack Server

1

Navigate to Server Directory


cd /path/to/assets-manager/server
2

Install Dependencies

npm install
3

Create Environment File

nano .env

Add the following configuration:

# Database Configuration
DB_HOST=localhost
DB_PORT=3306
DB_NAME=assettrack_db
DB_USERNAME=root
DB_PASSWORD=your_mysql_password

# JWT Configuration
JWT_SECRET=your-super-secure-jwt-secret-key-change-this-in-production
JWT_EXPIRES_IN=24h

# Server Configuration
PORT=3000
NODE_ENV=development

# CORS Configuration
ALLOWED_ORIGINS=http://localhost:5000,http://localhost:3000

# Rate Limiting
RATE_LIMIT_MAX=1000
AUTH_RATE_LIMIT_MAX=1000
API_RATE_LIMIT_MAX=1000

# Logging
LOG_LEVEL=info
4

Set Up Database

# Run migrations npm run db:migrate # Seed initial data npm run db:seed
5

Start the Server

npm run dev

Step 4: Install AsseTrack Client

1

Navigate to Client Directory

cd /path/to/assets-manager/client
2

Install Dependencies

npm install
3

Configure API Endpoint

nano src/config/config.ts

Update the configuration:

export const baseUrl = "http://localhost:3000";
export const apiUrl = `${baseUrl}/api`;
4

Start the Client

npm run dev

Step 5: Production Setup with PM2

1

Install PM2 Globally

sudo npm install -g pm2
2

Create PM2 Configuration

Create ecosystem.config.js in the server directory:

module.exports = { apps: [{ name: 'assettrack-server', script: './bin/www', instances: 1, autorestart: true, watch: false, max_memory_restart: '1G', env: { NODE_ENV: 'production', PORT: 3000 } }] };
3

Start with PM2

pm2 start ecosystem.config.js pm2 save pm2 startup

Troubleshooting

Common Issues

  • Permission denied: Check file permissions and ownership
  • Port already in use: Use netstat -tulpn | grep :3000 to find the process
  • MySQL connection failed: Verify MySQL is running with sudo systemctl status mysql
  • Node modules not found: Ensure you're in the correct directory and run npm install

Useful Commands

# Check Node.js version
node --version # Check MySQL status
sudo systemctl status mysql # Check running processes
ps aux | grep node # Check port usage
netstat -tulpn | grep :3000 # View logs
tail -f /path/to/assets-manager/server/logs/combined.log