3.4 KiB
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_rewriteenabled). - PHP: Version 8.0 or higher.
- Database: MariaDB 10.4+ or MySQL 5.7+.
- PHP Extensions:
pdo_mysqlcurlgd(for image processing)mbstringjson
2. Database Setup
- Create a Database: Create a new MySQL/MariaDB database (e.g.,
pos_system). - Configure Connection: Rename
db/config.php.exampletodb/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'); - Import Schema: Import the base schema from
db/schema.sqlinto your database. - Run Migrations: Import all SQL files located in
db/migrations/in sequential order (001, 002, etc.). - Initialize Data: Run the initialization script by visiting
http://your-domain.com/db/init.phpin 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.
Option A: Using the Setup Script (Recommended)
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
- File Permissions: Ensure the
assets/images/directory is writable by the web server for uploading product and ad images. - Login: Go to
http://your-domain.com/login.phpand log in with your new credentials. - 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.