38682-vm/INSTALL.md
2026-02-23 17:32:54 +00:00

3.4 KiB

Installation Guide

Follow these steps to set up the application on your server.

1. Requirements

Before you begin, ensure your server meets the following requirements:

  • Operating System: Linux, Windows, or macOS.
  • Web Server: Apache 2.4+ (with mod_rewrite enabled).
  • PHP: Version 8.0 or higher.
  • Database: MariaDB 10.4+ or MySQL 5.7+.
  • PHP Extensions:
    • pdo_mysql
    • curl
    • gd (for image processing)
    • mbstring
    • json

2. Database Setup

  1. Create a Database: Create a new MySQL/MariaDB database (e.g., pos_system).
  2. Configure Connection: Rename db/config.php.example to db/config.php (if not already present) and update the database credentials:
    define('DB_HOST', 'localhost');
    define('DB_NAME', 'your_database_name');
    define('DB_USER', 'your_username');
    define('DB_PASS', 'your_password');
    
  3. Import Schema: Import the base schema from db/schema.sql into your database.
  4. Run Migrations: Import all SQL files located in db/migrations/ in sequential order (001, 002, etc.).
  5. Initialize Data: Run the initialization script by visiting http://your-domain.com/db/init.php in your browser. This will seed categories, products, and outlets.

3. Creating a Super Admin

Since the initial setup does not include a default user for security reasons, you must create the first Administrator account.

Create a temporary file named setup_admin.php in the root directory with the following content:

<?php
require_once 'db/config.php';
require_once 'includes/functions.php';

$pdo = db();
$username = 'admin';
$password = password_hash('admin123', PASSWORD_DEFAULT);
$full_name = 'Super Admin';
$email = 'admin@example.com';

// Ensure the Administrator group exists
$stmt = $pdo->prepare("SELECT id FROM user_groups WHERE name = 'Administrator' LIMIT 1");
$stmt->execute();
$group_id = $stmt->fetchColumn();

if (!$group_id) {
    $pdo->exec("INSERT INTO user_groups (name, permissions) VALUES ('Administrator', 'all')");
    $group_id = $pdo->lastInsertId();
}

// Create the user
try {
    $stmt = $pdo->prepare("INSERT INTO users (group_id, username, password, full_name, email, is_active) VALUES (?, ?, ?, ?, ?, 1)");
    $stmt->execute([$group_id, $username, $password, $full_name, $email]);
    echo "Super Admin created successfully!<br>Username: admin<br>Password: admin123<br><b>Please delete this file immediately!</b>";
} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}

Visit http://your-domain.com/setup_admin.php and then delete the file.

Option B: Manual SQL

If you prefer SQL, run the following (replace the password hash with one generated via password_hash() in PHP):

INSERT INTO users (group_id, username, password, full_name, email, is_active) 
VALUES (1, 'admin', 'REPLACE_WITH_HASH', 'Super Admin', 'admin@example.com', 1);

4. Final Steps

  1. File Permissions: Ensure the assets/images/ directory is writable by the web server for uploading product and ad images.
  2. Login: Go to http://your-domain.com/login.php and log in with your new credentials.
  3. Company Settings: Navigate to Admin -> Company Settings to configure your restaurant name, address, and currency.

Security Note: Always ensure your db/config.php and .env files are not accessible from the public web.