================================================================================
          EDUBASEFORUM — AAPANEL FIX & DEPLOYMENT GUIDE (STEP-BY-STEP)
================================================================================

If your website is showing 403 Forbidden, 404 Not Found, 500 Internal Server Error,
or a blank page on aaPanel, it is caused by 3 quick aaPanel settings:

1. Running Directory is not set to /public
2. NGINX URL Rewrite (Pseudo-static) is missing
3. Folder permissions (storage folder needs www:www ownership)

Follow these 4 quick steps in your aaPanel dashboard to fix it in 2 minutes:

================================================================================
STEP 1: FIX RUNNING DIRECTORY (Fixes 403 Forbidden / Blank Page)
================================================================================
1. Log in to your aaPanel dashboard.
2. In the left sidebar, click on "Website".
3. Find your domain in the list and click on its domain name to open "Site Settings".
4. In the left menu of the popup, click on "Site directory".
5. You will see:
   - Site directory: `/www/wwwroot/yourdomain.com`
   - Running directory: It currently says `/`
6. Click the Running directory dropdown and change it to:
   👉 `/public`
7. Click the blue "Save" button!

================================================================================
STEP 2: ADD NGINX URL REWRITE (Fixes 404 Not Found on /install and routes)
================================================================================
aaPanel uses NGINX by default, which ignores .htaccess files. You must add the NGINX
rewrite rule so routes like /install, /login, and /dashboard work:

1. Still in your website's "Site Settings" popup in aaPanel:
2. In the left menu, click on "URL rewrite".
3. Look at the dropdown menu at the top:
   - Select "laravel5" (or "laravel") from the list.
4. It will automatically fill in:

   location / {
       try_files $uri $uri/ /index.php?$query_string;
   }

5. Click "Save"!

================================================================================
STEP 3: SET FILE PERMISSIONS (Fixes 500 Error / Blank Page)
================================================================================
aaPanel's PHP runs under the user `www`. The `storage` and `uploads` folders must be
writable by `www`:

1. In aaPanel's left sidebar, click on "Files".
2. Navigate to: `/www/wwwroot/yourdomain.com/`
3. Check the folder structure:
   Make sure files are NOT trapped inside an extra subfolder like `php-forum/`.
   You should see `app`, `public`, `storage`, `routes`, `.env` right here.
4. Right-click on the `storage` folder -> click "Permission".
   - Permission: Set to `777` (or `755`)
   - Owner: Set to `www`
   - Check the box: [x] "Apply to subdirectories"
   - Click "Save"!
5. Do the same for `/www/wwwroot/yourdomain.com/public/uploads` (Owner: `www`, 755).

================================================================================
STEP 4: PHP VERSION & EXTENSIONS
================================================================================
1. In your website "Site Settings", click "PHP version".
2. Make sure it is set to PHP 8.2 or PHP 8.3 (NOT PHP 7.4).
3. In aaPanel left menu, click "App Store" -> click on your PHP-8.2 -> "Setting":
   - Under "Install extensions", ensure these are installed:
     * fileinfo
     * pdo_mysql
     * gd
     * curl
     * mbstring

================================================================================
STEP 5: RUN THE WEB INSTALLER!
================================================================================
1. In aaPanel Files, check `/www/wwwroot/yourdomain.com/storage/`:
   If `installed.lock` exists, delete it so the installer is unlocked.
2. Open your browser and visit:
   👉 `https://yourdomain.com/install`
3. The graphical installer wizard will load cleanly!
4. Enter your database details from aaPanel (Database name, username, password) and
   your admin credentials.
5. Click "Install Now" — you are live!
================================================================================
