================================================================================
MindSparx.pro | AlphaCore OS - Complete Installation & Troubleshooting Guide
Resolving HTTP ERROR 500 & Full Webuzo / cPanel Configuration
================================================================================

This guide provides exact, step-by-step instructions to install MindSparx AlphaCore OS,
fix database privileges, and resolve the "HTTP ERROR 500 - This page isn't working right now"
condition immediately.

--------------------------------------------------------------------------------
PART 1: ROOT CAUSES OF "HTTP ERROR 500" AFTER DATABASE INSTALL
--------------------------------------------------------------------------------
When you see:
"This page isn’t working right now
mindsparx.pro can't currently handle this request.
HTTP ERROR 500"

On Webuzo, cPanel, or Apache servers running suPHP, suExec, or PHP-FPM, this is
caused by one of 4 specific misconfigurations:

1. INCORRECT FILE PERMISSIONS (Most Common on Webuzo):
   Under suPHP/suExec, any folder set to 777 or any PHP file set to 666/777 is
   deemed insecure and IMMEDIATELY terminates with a raw Apache HTTP 500 error!
   - ALL PHP files MUST be 644 (or 640).
   - ALL directories MUST be 755 (or 750).
   - NEVER use 777 on suExec servers!

2. MISSING HEADER.PHP OR UNHANDLED PDO EXCEPTION:
   If a script attempted to include a missing file (e.g. header.php) or an unhandled
   database connection exception halted execution without display_errors enabled,
   the browser defaults to its generic "HTTP ERROR 500" screen.

3. RESTRICTED APACHE DIRECTIVES IN .HTACCESS:
   If .htaccess contains directives such as 'Options +FollowSymLinks' or bare
   'Options -Indexes' and the host Apache AllowOverride does not permit Options,
   Apache aborts with HTTP 500 before PHP even runs.

4. DATABASE USER MISSING PERMISSIONS OR MYSQL SOCKET MISMATCH:
   If user 'mindsparx' does not have CREATE/ALTER/SELECT permissions on mindsparx_db,
   or if 'localhost' cannot connect to the MySQL UNIX socket.

--------------------------------------------------------------------------------
PART 2: STEP-BY-STEP FIX TO RESTORE FULL FUNCTIONALITY IMMEDIATELY
--------------------------------------------------------------------------------

STEP 1: FIX FILE AND DIRECTORY PERMISSIONS
------------------------------------------
Connect to your server via SSH (terminal) and navigate to your website root directory:

    cd /home/user/public_html   # or your target directory (e.g., /PHP or /MindSparx.pro)

Run the following two commands to reset all permissions correctly:

    # 1. Reset all directories to 755:
    find . -type d -exec chmod 755 {} \;

    # 2. Reset all files to 644:
    find . -type f -exec chmod 644 {} \;

    # 3. Ensure write permissions for logs and data folders:
    chmod 755 logs data

If using cPanel / Webuzo File Manager:
- Select all folders -> "Change Permissions" -> 755 (rwxr-xr-x).
- Select all .php files -> "Change Permissions" -> 644 (rw-r--r--).

STEP 2: ENSURE DATABASE USER CREDENTIALS & PERMISSIONS
------------------------------------------------------
In Webuzo / cPanel MySQL Manager or via MySQL CLI as root:

    mysql -u root -p

Execute:
    CREATE DATABASE IF NOT EXISTS mindsparx_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
    CREATE USER IF NOT EXISTS 'mindsparx'@'localhost' IDENTIFIED BY '##MindSparx##';
    CREATE USER IF NOT EXISTS 'mindsparx'@'127.0.0.1' IDENTIFIED BY '##MindSparx##';
    GRANT ALL PRIVILEGES ON mindsparx_db.* TO 'mindsparx'@'localhost';
    GRANT ALL PRIVILEGES ON mindsparx_db.* TO 'mindsparx'@'127.0.0.1';
    FLUSH PRIVILEGES;

STEP 3: RUN THE 1-CLICK WEB INSTALLER
-------------------------------------
Open your browser and navigate to:
    https://mindsparx.pro/install.php
    (or https://mindsparx.pro/MindSparx.pro/install.php)

1. The installer will display all green checks for PHP 8+, PDO MySQL, and write permissions.
2. Click "Run 1-Click Database Setup & Migration".
3. The installer creates all tables, seeds default clinical accounts, and generates db_config.php.

STEP 4: VERIFY SERVER ERROR LOGS
--------------------------------
If you still see any issues, inspect the error log files:
1. Application Log: /logs/error.log and /logs/db_errors.log
2. Webuzo Apache Log: /usr/local/apps/apache2/logs/error_log
3. cPanel Apache Log: /usr/local/apache/logs/error_log

To view in real time via SSH:
    tail -f logs/error.log

--------------------------------------------------------------------------------
PART 3: DEFAULT CLINICAL LOGINS
--------------------------------------------------------------------------------
Super Admin:
- Username: mindsparx
- Password: ##MindSparx##
- Passkey:  ##MindSparx##
- URL:      /admin/dashboard.php

Practice Director / Lead Clinician:
- Username: SkySteele
- Password: ##MindSparx##
- Role:     Professional

Client Health Portal Test:
- Username: demo_client
- Password: ##MindSparx##
- Role:     Client

Free Download Portal:
- URL:      /download.php (Direct .zip download)

Modular Addons:
- URL:      /components_manager.php

================================================================================
Support & Updates: https://mindsparx.pro
================================================================================
