# Deploy Atlas OS to wiziv.net on WHM/cPanel

This project is already a complete Laravel application. The recommended deployment keeps the application outside the public web directory and exposes only `public/`.

## 1. Prepare the domain

In cPanel **Domains**, set the document root for `wiziv.net` to:

```text
/home/wiziv/atlas-os/public
```

Use **MultiPHP Manager** to assign PHP 8.4 to `wiziv.net`. In **Select PHP Version / Extensions** or WHM EasyApache, confirm Ctype, cURL, DOM, Fileinfo, Filter, Hash, Mbstring, OpenSSL, PCRE, PDO MySQL, Session, Tokenizer, and XML.

Do not continue until AutoSSL gives `https://wiziv.net` a valid certificate.

## 2. Create the database

In **MySQL Databases**:

1. Create a database such as `wiziv_atlas`.
2. Create a dedicated user such as `wiziv_atlas` with a strong generated password.
3. Grant that user **All Privileges** on this database only.
4. Keep the final cPanel-prefixed names; they may differ from the examples.

## 3. Upload the application

Upload and extract the package as:

```text
/home/wiziv/atlas-os
```

If Installatron has already created a Laravel project, preserve its `.env` only after verifying it contains no unwanted values, then replace the application source with this package. Do not copy an old `APP_KEY` from another website.

## 4. Configure `.env`

From cPanel Terminal:

```bash
cd /home/wiziv/atlas-os
cp .env.example .env
```

Edit `.env` through cPanel File Manager and set the real cPanel database name, user, and password. Keep:

```dotenv
APP_ENV=production
APP_DEBUG=false
APP_URL=https://wiziv.net
APP_TIMEZONE=Africa/Cairo
SESSION_SECURE_COOKIE=true
ATLAS_AI_ENABLED=false
```

## 5. Install and initialize

Run:

```bash
cd /home/wiziv/atlas-os
composer install --no-dev --optimize-autoloader
php artisan key:generate
php artisan migrate --force
php artisan atlas:admin
php artisan optimize
```

The administrator command asks for your name, email, organization, and a hidden password. It does not print or store a default password in the project.

## 6. Permissions

Use the cPanel account user, not root, as owner. Directories normally use `755` and files `644`. Laravel must be able to write to:

```text
storage/
bootstrap/cache/
```

On a normal cPanel account, these commands are usually sufficient:

```bash
chmod -R u+rwX,g+rwX storage bootstrap/cache
```

Do not use `777`.

## 7. Cron and queue

V1 has no required asynchronous workload, but configure Laravel's scheduler now in cPanel **Cron Jobs**:

```cron
* * * * * cd /home/wiziv/atlas-os && /usr/local/bin/ea-php84 artisan schedule:run >> /dev/null 2>&1
```

Confirm the actual PHP 8.4 binary with `which php` or cPanel documentation before saving the cron entry.

## 8. Verify

```bash
php artisan atlas:status
php artisan about --only=environment
php artisan route:list
```

Then open `https://wiziv.net/login`, sign in, create an operating cycle, create one record of each type, upload a test PDF, download it, and inspect the audit history.

## 9. Backups and updates

Back up the MySQL database, `.env`, `storage/app/private`, and the application release. Verify a restoration rather than assuming a backup is recoverable.

For each release:

```bash
php artisan down --secret="temporary-maintenance-path"
composer install --no-dev --optimize-autoloader
php artisan migrate --force
php artisan optimize
php artisan up
```

Keep the maintenance secret private and change it for each deployment.

