================================================================================
  ENTREPRENR EDUCATION INDUCTION LMS - DEPLOYMENT GUIDE
================================================================================

Version: 2.0
Last Updated: January 27, 2026
Platform: Laravel 11 + React (Inertia.js)

================================================================================
TABLE OF CONTENTS
================================================================================

1. SYSTEM REQUIREMENTS
2. PRE-INSTALLATION CHECKLIST
3. INSTALLATION STEPS
4. DATABASE SETUP
5. CONFIGURATION
6. FILE PERMISSIONS
7. POST-INSTALLATION TASKS
8. TROUBLESHOOTING
9. FEATURES OVERVIEW
10. PAYMENT GATEWAYS SETUP
11. MULTI-LANGUAGE SETUP
12. BACKUP & MAINTENANCE

================================================================================
1. SYSTEM REQUIREMENTS
================================================================================

SERVER REQUIREMENTS:
- PHP: >= 8.2
- Composer: Latest version
- Node.js: >= 18.x
- NPM: >= 9.x
- MySQL: >= 8.0 or MariaDB >= 10.3
- Web Server: Apache 2.4+ or Nginx 1.18+
- SSL Certificate (recommended for production)

PHP EXTENSIONS REQUIRED:
- BCMath
- Ctype
- cURL
- DOM
- Fileinfo
- JSON
- Mbstring
- OpenSSL
- PDO
- PDO_MySQL
- Tokenizer
- XML
- GD or Imagick (for QR codes and certificates)
- ZIP

RECOMMENDED SERVER SPECS:
- RAM: Minimum 2GB (4GB+ recommended)
- Storage: Minimum 1GB free space
- CPU: 2+ cores

================================================================================
2. PRE-INSTALLATION CHECKLIST
================================================================================

Before uploading files:

[ ] Verify server meets all requirements
[ ] Create MySQL database and user
[ ] Note database credentials (host, name, username, password)
[ ] Obtain domain/subdomain SSL certificate
[ ] Prepare payment gateway credentials (Stripe/PayPal/Paystack)
[ ] Have FTP/SSH access to server
[ ] Backup existing files if upgrading

================================================================================
3. INSTALLATION STEPS
================================================================================

STEP 1: UPLOAD FILES
---------------------
1. Extract the deployment package
2. Upload ALL files to your hosting directory
   - For root domain: /public_html/ or /www/
   - For subdomain: /public_html/subdomain/ or /www/subdomain/
3. Ensure all files and folders are uploaded completely

IMPORTANT FILE STRUCTURE:
your-root/
├── app/                    (Application logic)
├── bootstrap/              (Framework bootstrap)
├── config/                 (Configuration files)
├── database/              (Migrations, seeders)
├── public/                (Web root - point domain here)
├── resources/             (Views, React components)
├── routes/                (Route definitions)
├── storage/               (Logs, cache, uploads)
├── vendor/                (PHP dependencies)
├── node_modules/          (JS dependencies - if included)
├── .env.example           (Environment template)
├── artisan                (Laravel CLI)
├── composer.json          (PHP dependencies)
├── package.json           (Node dependencies)
└── vite.config.js         (Build configuration)

STEP 2: INSTALL PHP DEPENDENCIES
----------------------------------
Connect via SSH and run:

cd /path/to/your/installation
composer install --optimize-autoloader --no-dev

If composer not available, install it:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
php -r "unlink('composer-setup.php');"
php composer.phar install --optimize-autoloader --no-dev

STEP 3: INSTALL NODE DEPENDENCIES & BUILD ASSETS
-------------------------------------------------
npm install
npm run build

This compiles all React/TypeScript assets for production.

STEP 4: ENVIRONMENT CONFIGURATION
----------------------------------
1. Copy .env.example to .env:
   cp .env.example .env

2. Generate application key:
   php artisan key:generate

3. Edit .env file with your settings (see Section 5)

STEP 5: SET UP WEB SERVER
--------------------------

FOR APACHE:
- Ensure .htaccess is in the public/ directory
- Enable mod_rewrite
- Point document root to: /path/to/installation/public

FOR NGINX:
Add to server block:

server {
    listen 80;
    server_name yourdomain.com;
    root /path/to/installation/public;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-Content-Type-Options "nosniff";

    index index.php;

    charset utf-8;

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

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}

STEP 6: SET FILE PERMISSIONS
-----------------------------
chmod -R 755 /path/to/installation
chmod -R 775 /path/to/installation/storage
chmod -R 775 /path/to/installation/bootstrap/cache
chown -R www-data:www-data /path/to/installation

(Replace www-data with your web server user)

STEP 7: DATABASE SETUP
-----------------------
Run migrations to create tables:

php artisan migrate --force

Run seeders (optional - creates default admin):

php artisan db:seed

Default Admin Credentials (if seeded):
Email: admin@example.com
Password: password
IMPORTANT: Change these immediately after first login!

STEP 8: OPTIMIZE FOR PRODUCTION
--------------------------------
php artisan config:cache
php artisan route:cache
php artisan view:cache
php artisan optimize

STEP 9: CREATE STORAGE LINK
----------------------------
php artisan storage:link

This creates a symbolic link from public/storage to storage/app/public

STEP 10: VERIFY INSTALLATION
-----------------------------
Visit your domain in a browser. You should see the login page.

================================================================================
4. DATABASE SETUP
================================================================================

CREATING DATABASE:
------------------
Via cPanel/phpMyAdmin:
1. Login to cPanel
2. Go to MySQL Databases
3. Create new database (e.g., username_ee_lms)
4. Create new user with strong password
5. Add user to database with ALL PRIVILEGES

Via Command Line:
mysql -u root -p
CREATE DATABASE ee_lms CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'ee_user'@'localhost' IDENTIFIED BY 'strong_password';
GRANT ALL PRIVILEGES ON ee_lms.* TO 'ee_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

IMPORTING DATABASE (if provided):
----------------------------------
mysql -u username -p database_name < database_backup.sql

Or via phpMyAdmin:
1. Select your database
2. Click "Import" tab
3. Choose SQL file
4. Click "Go"

DATABASE TABLES CREATED:
------------------------
The application creates these tables automatically:
- users                    (User accounts)
- courses                  (Course catalog)
- lessons                  (Course lessons)
- topics                   (Lesson topics/sections)
- quizzes                  (Course assessments)
- quiz_questions           (Quiz questions)
- quiz_answers             (Answer options)
- quiz_attempts            (User quiz attempts)
- course_enrollments       (User enrollments)
- user_progress            (Learning progress)
- certificates             (Completion certificates)
- payments                 (Payment records)
- custom_pages             (CMS pages)
- categories               (Course categories)
- languages                (Multi-language support)
- settings                 (System settings)
- roles/permissions        (Access control)
- sessions                 (User sessions)
- cache                    (Application cache)
- jobs                     (Background jobs)

================================================================================
5. CONFIGURATION
================================================================================

EDIT .env FILE:
---------------

# Application Settings
APP_NAME="Your LMS Name"
APP_ENV=production
APP_DEBUG=false                    # MUST be false in production
APP_URL=https://yourdomain.com

# Database Configuration
DB_CONNECTION=mysql
DB_HOST=127.0.0.1                  # Or your DB host
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=your_database_user
DB_PASSWORD=your_database_password

# Session & Cache
SESSION_DRIVER=database
CACHE_STORE=database
QUEUE_CONNECTION=database

# Mail Configuration (for notifications)
MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com           # Your SMTP host
MAIL_PORT=587
MAIL_USERNAME=your-email@gmail.com
MAIL_PASSWORD=your-app-password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=noreply@yourdomain.com
MAIL_FROM_NAME="${APP_NAME}"

# Stripe Payment Gateway
STRIPE_KEY=pk_live_xxxxxxxxxxxxx   # Your Stripe public key
STRIPE_SECRET=sk_live_xxxxxxxxxxxxx # Your Stripe secret key
STRIPE_WEBHOOK_SECRET=whsec_xxxxxx  # Webhook signing secret

# PayPal Configuration
PAYPAL_MODE=live                    # or 'sandbox' for testing
PAYPAL_CLIENT_ID=your_paypal_client_id
PAYPAL_SECRET=your_paypal_secret

# Paystack Configuration
PAYSTACK_PUBLIC_KEY=pk_live_xxxxxxx
PAYSTACK_SECRET_KEY=sk_live_xxxxxxx
PAYSTACK_PAYMENT_URL=https://api.paystack.co
PAYSTACK_MERCHANT_EMAIL=your@email.com

# File Storage
FILESYSTEM_DISK=local              # or 's3' for AWS

# Timezone
APP_TIMEZONE=UTC                   # Change to your timezone

================================================================================
6. FILE PERMISSIONS
================================================================================

CRITICAL DIRECTORIES (Must be writable):
-----------------------------------------
storage/                           775
storage/app/                       775
storage/app/public/                775
storage/framework/                 775
storage/framework/cache/           775
storage/framework/sessions/        775
storage/framework/views/           775
storage/logs/                      775
bootstrap/cache/                   775

PUBLIC ASSETS (Read-only):
--------------------------
public/                            755
public/build/                      755
public/assets/                     755

SECURITY:
---------
.env                               600 (read-only for owner)
composer.json                      644
package.json                       644

Never set 777 permissions in production!

================================================================================
7. POST-INSTALLATION TASKS
================================================================================

IMMEDIATE ACTIONS:
------------------
1. Login as admin
2. Change default admin password
3. Update site settings (Settings → General)
4. Upload your logo (Settings → Branding)
5. Configure payment gateways
6. Create user roles and permissions
7. Set up email templates
8. Create course categories
9. Test payment flow with small amount
10. Enable SSL and force HTTPS

RECOMMENDED SETUP:
------------------
1. Create tutor accounts
2. Set up course categories
3. Create sample course to test flow
4. Configure certificate templates
5. Set up custom pages (About, Contact, Terms)
6. Test quiz functionality
7. Test enrollment and payment
8. Test certificate generation
9. Set up automated backups
10. Configure monitoring/logging

SECURITY CHECKLIST:
-------------------
[ ] APP_DEBUG=false in .env
[ ] Strong database password
[ ] .env file not publicly accessible
[ ] SSL certificate installed
[ ] Force HTTPS in .htaccess
[ ] Regular backups scheduled
[ ] Update all default passwords
[ ] Disable directory listing
[ ] Keep Laravel and dependencies updated
[ ] Configure rate limiting
[ ] Set up firewall rules

================================================================================
8. TROUBLESHOOTING
================================================================================

PROBLEM: "500 Internal Server Error"
SOLUTION:
- Check storage and bootstrap/cache permissions
- Review storage/logs/laravel.log
- Verify .env configuration
- Clear cache: php artisan cache:clear

PROBLEM: "Mix Manifest Not Found"
SOLUTION:
- Run: npm run build
- Clear cache: php artisan view:clear
- Check public/build directory exists

PROBLEM: "Database Connection Error"
SOLUTION:
- Verify database credentials in .env
- Ensure database exists
- Check database user has proper privileges
- Test connection: php artisan tinker
  Then: DB::connection()->getPdo();

PROBLEM: "Blank Page / White Screen"
SOLUTION:
- Enable error display temporarily
- Check PHP error logs
- Verify PHP version is 8.2+
- Check all PHP extensions installed

PROBLEM: "Payment Not Working"
SOLUTION:
- Verify payment gateway credentials
- Check webhook URLs configured
- Review payment logs in database
- Test in sandbox/test mode first

PROBLEM: "Assets Not Loading (CSS/JS)"
SOLUTION:
- Verify npm run build completed
- Check public/build directory exists
- Clear browser cache
- Verify web server serves static files

PROBLEM: "Permission Denied Errors"
SOLUTION:
- Fix permissions: chmod -R 775 storage bootstrap/cache
- Check owner: chown -R www-data:www-data .
- Verify SELinux not blocking (if applicable)

PROBLEM: "CSRF Token Mismatch"
SOLUTION:
- Clear cookies
- Check APP_URL in .env matches actual URL
- Clear cache: php artisan cache:clear
- Verify session driver working

USEFUL COMMANDS:
----------------
Clear all caches:
php artisan cache:clear
php artisan config:clear
php artisan route:clear
php artisan view:clear

Check application:
php artisan about

View logs:
tail -f storage/logs/laravel.log

Database console:
php artisan tinker

================================================================================
9. FEATURES OVERVIEW
================================================================================

ADMIN FEATURES:
---------------
✓ Full course management (CRUD)
✓ Lesson and topic organization
✓ Quiz creation with multiple question types
✓ User management (students, tutors, admins)
✓ Payment tracking and reporting
✓ Certificate generation with QR codes
✓ Custom page builder
✓ Multi-language content management
✓ Category management
✓ Settings and configuration
✓ Analytics and reporting
✓ Role-based access control

TUTOR FEATURES:
---------------
✓ Create and manage own courses
✓ Upload course materials (video, audio, documents)
✓ Create lessons and topics
✓ Build quizzes and assessments
✓ Track student progress
✓ View enrollment statistics
✓ Manage course pricing
✓ Publish/unpublish courses
✓ Multi-language course support

STUDENT FEATURES:
-----------------
✓ Browse course catalog
✓ Filter by category
✓ Enroll in free courses
✓ Purchase paid courses
✓ Track learning progress
✓ Take quizzes with instant feedback
✓ View performance analytics
✓ Download certificates
✓ Access code enrollment
✓ Multi-language interface
✓ Mobile-responsive design

COURSE FEATURES:
----------------
✓ Free and paid courses
✓ Multiple pricing models (fixed, discounted)
✓ Course prerequisites
✓ Estimated study time
✓ Category organization
✓ Multi-language support (10+ languages)
✓ Video/audio/text content
✓ Downloadable resources
✓ Progress tracking
✓ Completion certificates

QUIZ FEATURES:
--------------
✓ Multiple choice questions
✓ Single and multiple correct answers
✓ Auto-submit on timer
✓ Instant feedback
✓ Retake with penalty system
✓ Progress saving
✓ Performance analytics
✓ Pass/fail criteria
✓ Detailed result reports

PAYMENT FEATURES:
-----------------
✓ Stripe integration
✓ PayPal integration
✓ Paystack integration (African markets)
✓ Secure payment processing
✓ Payment history tracking
✓ Automated enrollment after payment
✓ Refund tracking

CERTIFICATE FEATURES:
---------------------
✓ Auto-generated on course completion
✓ PDF download
✓ QR code verification
✓ Unique certificate IDs
✓ Custom templates
✓ Digital signatures

MULTI-LANGUAGE SUPPORT:
-----------------------
✓ English (default)
✓ Spanish
✓ French
✓ German
✓ Italian
✓ Portuguese
✓ Dutch
✓ Polish
✓ Arabic
✓ Chinese
✓ Easy to add more languages

================================================================================
10. PAYMENT GATEWAYS SETUP
================================================================================

STRIPE SETUP:
-------------
1. Create account at https://stripe.com
2. Get API keys from Dashboard → Developers → API keys
3. Add to .env:
   STRIPE_KEY=pk_live_xxxxxxxxx
   STRIPE_SECRET=sk_live_xxxxxxxxx
4. Set up webhooks:
   - URL: https://yourdomain.com/stripe/webhook
   - Events: payment_intent.succeeded, payment_intent.payment_failed
5. Add webhook secret to .env:
   STRIPE_WEBHOOK_SECRET=whsec_xxxxxxxxx

PAYPAL SETUP:
-------------
1. Create account at https://developer.paypal.com
2. Create REST API app
3. Get Client ID and Secret
4. Add to .env:
   PAYPAL_MODE=live
   PAYPAL_CLIENT_ID=xxxxxxxxx
   PAYPAL_SECRET=xxxxxxxxx
5. Configure IPN/webhook URL:
   https://yourdomain.com/paypal/webhook

PAYSTACK SETUP (For Africa):
-----------------------------
1. Create account at https://paystack.com
2. Get API keys from Settings → API Keys & Webhooks
3. Add to .env:
   PAYSTACK_PUBLIC_KEY=pk_live_xxxxxxxxx
   PAYSTACK_SECRET_KEY=sk_live_xxxxxxxxx
   PAYSTACK_MERCHANT_EMAIL=your@email.com
4. Set webhook URL:
   https://yourdomain.com/paystack/webhook

TESTING PAYMENTS:
-----------------
1. Use sandbox/test mode first
2. Test card numbers:
   - Stripe: 4242 4242 4242 4242
   - PayPal: Use sandbox accounts
   - Paystack: Test cards from documentation
3. Verify enrollment after payment
4. Check payment records in admin panel

================================================================================
11. MULTI-LANGUAGE SETUP
================================================================================

ENABLING LANGUAGES:
-------------------
1. Login as admin
2. Go to Settings → Languages
3. Enable desired languages
4. Set default language

TRANSLATING CONTENT:
--------------------
Courses:
- Edit course
- Click language tabs (EN, ES, FR, etc.)
- Enter translations for each field
- Save

Custom Pages:
- Edit page
- Fill content for each language
- Preview before saving

UI Translation Files:
Located in: resources/lang/
- en.json (English)
- es.json (Spanish)
- fr.json (French)
etc.

Edit these files to translate interface elements.

LANGUAGE SELECTOR:
------------------
Users can switch language from header dropdown.
Their preference is saved in session.

================================================================================
12. BACKUP & MAINTENANCE
================================================================================

BACKUP STRATEGY:
----------------

1. DATABASE BACKUP (Daily):
   mysqldump -u username -p database_name > backup_$(date +%Y%m%d).sql

   Or via cPanel backup tool

2. FILES BACKUP (Weekly):
   tar -czf lms_backup_$(date +%Y%m%d).tar.gz /path/to/installation

3. AUTOMATED BACKUPS:
   Set up cron jobs:
   
   # Daily database backup at 2 AM
   0 2 * * * mysqldump -u user -ppassword db_name > /backups/db_$(date +\%Y\%m\%d).sql

   # Weekly full backup on Sunday at 3 AM
   0 3 * * 0 tar -czf /backups/full_$(date +\%Y\%m\%d).tar.gz /var/www/lms

MAINTENANCE TASKS:
------------------

Daily:
- Monitor error logs
- Check disk space
- Verify backups completed

Weekly:
- Review user activity
- Check payment transactions
- Update content

Monthly:
- Update Laravel and dependencies
- Security audit
- Performance optimization
- Database optimization:
  php artisan optimize:clear
  mysql> OPTIMIZE TABLE table_name;

UPDATING APPLICATION:
---------------------
1. Backup everything first!
2. Put site in maintenance mode:
   php artisan down
3. Pull/upload new files
4. Update dependencies:
   composer install --no-dev
   npm install && npm run build
5. Run migrations:
   php artisan migrate --force
6. Clear and rebuild caches:
   php artisan optimize
7. Bring site back up:
   php artisan up

MONITORING:
-----------
- Set up uptime monitoring (UptimeRobot, Pingdom)
- Monitor error logs daily
- Track server resources (CPU, RAM, disk)
- Set up email alerts for critical errors
- Use Laravel Telescope for debugging (dev only)

LOG FILES:
----------
Laravel logs: storage/logs/laravel.log
Web server logs: /var/log/apache2/ or /var/log/nginx/
PHP error log: /var/log/php-fpm/error.log

Rotate logs to prevent disk full:
Add to crontab:
0 0 * * * find /path/to/storage/logs -name "*.log" -mtime +30 -delete

================================================================================
SUPPORT & DOCUMENTATION
================================================================================

For additional support:
- Check application documentation in /docs folder
- Review Laravel documentation: https://laravel.com/docs
- Check Inertia.js docs: https://inertiajs.com
- Review payment gateway documentation

================================================================================
END OF DEPLOYMENT GUIDE
================================================================================

QUICK START SUMMARY:
--------------------
1. Upload files to web directory
2. Run: composer install --no-dev
3. Run: npm install && npm run build
4. Copy .env.example to .env
5. Run: php artisan key:generate
6. Configure .env (database, mail, payments)
7. Run: php artisan migrate --force
8. Set permissions: chmod -R 775 storage bootstrap/cache
9. Run: php artisan storage:link
10. Run: php artisan optimize
11. Visit your domain and login!

Happy Learning! 🎓
