# Doctor Appointment System - cPanel Installation Guide

## Important

This is a Laravel PHP application.

**Do not upload the ZIP and point the domain to the project root.**

The domain document root must point to:

```text
public/
```

The `app/`, `config/`, `database/`, and `.env` files must stay outside the public web root.

---

# Part 1 - Check cPanel Hosting

Before uploading, confirm your hosting supports:

- PHP 8.2 or newer
- MySQL/MariaDB
- PHP extensions:
  - BCMath
  - Ctype
  - cURL
  - DOM
  - Fileinfo
  - JSON
  - Mbstring
  - OpenSSL
  - PDO
  - PDO MySQL
  - Tokenizer
  - XML
- Composer / PHP Composer

In cPanel:

```text
Software → MultiPHP Manager
```

Set the domain PHP version to:

```text
PHP 8.2+
```

Then open:

```text
Select PHP Version → Extensions
```

Enable the required extensions.

---

# Part 2 - Create the MySQL Database

Open:

```text
cPanel → MySQL Databases
```

Create:

```text
Database: doctor_appointment
User: doctor_app_user
Password: YOUR_STRONG_PASSWORD
```

Add the database user to the database.

Select:

```text
ALL PRIVILEGES
```

IMPORTANT:

cPanel often adds a prefix.

Example:

```text
YourCPUser_doctor_appointment
YourCPUser_doctor_app_user
```

Use the exact cPanel database name and username.

---

# Part 3 - Upload the ZIP

Open:

```text
cPanel → File Manager
```

Recommended structure:

```text
/home/YOUR_CPANEL_USER/
    doctor-appointment/
    public_html/
```

Upload:

```text
doctor-appointment-system-phase1-12.zip
```

to:

```text
/home/YOUR_CPANEL_USER/
```

Extract the ZIP into:

```text
/home/YOUR_CPANEL_USER/doctor-appointment/
```

The final structure must look like:

```text
/home/YOUR_CPANEL_USER/doctor-appointment/
    app/
    bootstrap/
    config/
    database/
    public/
    resources/
    routes/
    artisan
    composer.json
```

---

# Part 4 - Configure the Domain Document Root

Go to:

```text
cPanel → Domains
```

Edit your domain.

Set document root to:

```text
/home/YOUR_CPANEL_USER/doctor-appointment/public
```

Example:

```text
/home/arunkumar/doctor-appointment/public
```

If your hosting does not allow changing the primary domain document root, ask hosting support to set the Laravel `public/` directory as the domain document root.

**Do not copy `app/` or `.env` into public_html.**

---

# Part 5 - Open cPanel Terminal

Open:

```text
cPanel → Terminal
```

Run:

```bash
cd /home/YOUR_CPANEL_USER/doctor-appointment
```

Check:

```bash
php -v
composer --version
```

PHP must be:

```text
8.2 or newer
```

---

# Part 6 - Install PHP Dependencies

Run:

```bash
composer install --no-dev --optimize-autoloader
```

This downloads Laravel and the required PHP packages.

If Composer gives a PHP version error, change PHP version in:

```text
MultiPHP Manager
```

---

# Part 7 - Create the .env File

Run:

```bash
cp .env.example .env
```

Edit:

```text
File Manager → doctor-appointment → .env
```

Change:

```env
APP_NAME="Doctor Appointment System"
APP_ENV=production
APP_DEBUG=false
APP_URL=https://YOUR-DOMAIN.COM
```

Database:

```env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=YOUR_CPANEL_DATABASE
DB_USERNAME=YOUR_CPANEL_DATABASE_USER
DB_PASSWORD=YOUR_DATABASE_PASSWORD
```

Example:

```env
DB_DATABASE=arunkumar_doctor_appointment
DB_USERNAME=arunkumar_doctor_app_user
DB_PASSWORD=MyStrongPassword
```

---

# Part 8 - Generate Application Key

From Terminal:

```bash
php artisan key:generate --force
```

You should see:

```text
Application key set successfully.
```

---

# Part 9 - Create Database Tables

Run:

```bash
php artisan migrate --seed --force
```

This creates all tables and default system settings.

---

# Part 10 - Create Storage Link

Run:

```bash
php artisan storage:link
```

If the command says the link already exists, that is okay.

---

# Part 11 - Clear and Cache Laravel

Run:

```bash
php artisan optimize:clear
```

Then:

```bash
php artisan config:cache
php artisan route:cache
php artisan view:cache
```

---

# Part 12 - Start the Queue Worker

Phase 10-12 notification features use queues.

In cPanel:

```text
Cron Jobs
```

Add:

```text
Every 1 minute
```

Command:

```bash
cd /home/YOUR_CPANEL_USER/doctor-appointment && php artisan queue:work --queue=notifications,default --stop-when-empty --tries=3 >> /dev/null 2>&1
```

IMPORTANT:

For some shared hosting plans, `queue:work` may be restricted.

If the queue worker is not allowed, ask hosting support to enable a persistent Laravel queue worker.

---

# Part 13 - Add Laravel Scheduler

In:

```text
cPanel → Cron Jobs
```

Add another cron:

```text
Every minute
```

Command:

```bash
cd /home/YOUR_CPANEL_USER/doctor-appointment && php artisan schedule:run >> /dev/null 2>&1
```

This runs:

```text
Appointment reminders
Database backup
```

---

# Part 14 - Open the Website

Open:

```text
https://YOUR-DOMAIN.COM
```

You should see the login page.

---

# Default Admin Login

```text
Email:
admin@example.com

Password:
Admin@12345
```

**Immediately change the password after first login.**

---

# Part 15 - Test the System

Test in this order:

## 1. Login

```text
admin@example.com
```

## 2. Specialty

Create or view a specialty.

## 3. Doctor

Create a doctor.

## 4. Doctor Availability

Set a doctor schedule.

## 5. Patient

Create a patient.

## 6. Appointment

Book an appointment.

## 7. Payment

Configure Razorpay before testing live payment.

## 8. Notifications

Configure SMTP, SMS, WhatsApp and Firebase separately.

## 9. System Health

Open:

```text
/system-health
```

Expected:

```text
Application: OK
Database: OK
Cache: OK
Storage: OK
```

---

# Phase 16 - Configure Payment

Edit `.env`:

```env
RAZORPAY_KEY_ID=
RAZORPAY_KEY_SECRET=
```

Add Razorpay credentials.

Clear config:

```bash
php artisan config:clear
php artisan config:cache
```

---

# Phase 17 - Configure Firebase

Set:

```env
FIREBASE_ENABLED=true
FIREBASE_PROJECT_ID=YOUR_PROJECT_ID
FIREBASE_SERVICE_ACCOUNT=/home/YOUR_CPANEL_USER/firebase/service-account.json
```

Do not put the JSON file inside:

```text
public/
public_html/
```

Then:

```bash
php artisan config:clear
php artisan config:cache
```

---

# Phase 18 - Troubleshooting

## 500 Error

Run:

```bash
php artisan optimize:clear
```

Check:

```text
storage/logs/laravel.log
```

## Database Error

Check:

```env
DB_DATABASE
DB_USERNAME
DB_PASSWORD
```

Remember cPanel database names usually have a prefix.

## Composer Error

Check:

```bash
php -v
composer --version
```

Use PHP 8.2+.

## Permission Error

Set:

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

to writable by the application.

Do not make the entire project `777`.

## Queue Not Working

Check:

```bash
php artisan queue:failed
```

Then:

```bash
php artisan queue:retry all
```

## Domain Shows Directory Listing

Your document root is wrong.

Set it to:

```text
doctor-appointment/public
```

---

# Final Security Checklist

Before production:

```text
APP_DEBUG=false
```

Change the default admin password.

Do not expose `.env`.

Do not expose the `app/` directory.

Do not expose database credentials.

Do not commit Firebase service account JSON.

Enable HTTPS.

Use a strong database password.
