Sindbad~EG File Manager
# Live Server Deployment Guide - Fix 500 Errors
## Common Causes of 500 Errors & Solutions
### 1. ✅ FIXED: .htaccess Hardcoded Paths
**Issue:** `.htaccess` had hardcoded `/copmadinaarea/` paths
**Fixed:** Changed to relative paths
```apache
# OLD (Wrong)
ErrorDocument 404 /copmadinaarea/404.php
# NEW (Correct)
ErrorDocument 404 /404.php
```
### 2. File Permissions (Most Common)
**Fix on Linux/Unix servers:**
```bash
# Set correct permissions
chmod 755 -R /path/to/application
chmod 777 -R /path/to/application/uploads
```
Or via FTP/cPanel:
- Folders: `755` (rwxr-xr-x)
- Files: `644` (rw-r--r--)
- `uploads/` folder: `777` (rwxrwxrwx)
### 3. PHP Version Issues
**Required:** PHP 7.4 or higher
**Check:** Run `server_check.php` to verify
If PHP version is old, update via cPanel or hosting control panel.
### 4. Missing PHP Extensions
**Required extensions:**
- `pdo`, `pdo_mysql` - Database
- `gd` - Image processing
- `mbstring` - String handling
- `zip` - File compression
- `curl` - HTTP requests
**Enable via cPanel:** PHP Extensions → Select All Required
### 5. Database Configuration
**Update:** `config/database.php`
```php
define('DB_HOST', 'localhost'); // or your DB host
define('DB_USER', 'copmadinaarea_portal');
define('DB_PASS', 'Swanzy10@@@');
define('DB_NAME', 'copmadinaarea_portal');
```
**Note:** Some hosts use `127.0.0.1` instead of `localhost`
### 6. Composer Dependencies
If you uploaded manually, vendor files might be missing:
```bash
# SSH into server and run:
cd /path/to/application
composer install --no-dev --optimize-autoloader
```
Or download/upload the `vendor/` folder from local.
### 7. .htaccess Issues
#### Option A: Disable .htaccess temporarily
Rename `.htaccess` to `.htaccess.bak` to test if it's causing the issue.
#### Option B: Check mod_rewrite
Some servers don't support all directives. Try minimal .htaccess:
```apache
# Minimal .htaccess for testing
RewriteEngine On
DirectoryIndex index.php
Options -Indexes
```
#### Option C: Remove PHP settings
Some shared hosts don't allow `php_value` in .htaccess:
```apache
# Comment out these lines if causing issues:
# php_value upload_max_filesize 10M
# php_value post_max_size 10M
# php_value max_execution_time 300
# php_value max_input_time 300
```
### 8. Error Log Analysis
**Check server error logs:**
- cPanel: Error Logs
- Direct access: `/var/log/apache2/error.log`
- Or: `~/logs/error.log`
Common errors:
- "Permission denied" → File permissions issue
- "Failed opening required" → Missing files
- "Call to undefined function" → Missing PHP extension
---
## Step-by-Step Deployment
### Pre-Upload Checklist
- [x] Database credentials updated in `config/database.php`
- [x] `.htaccess` paths fixed (relative)
- [x] `BASE_URL` auto-detection enabled
### Upload Steps
1. **Create Database**
- cPanel → MySQL Databases
- Create database: `copmadinaarea_portal`
- Create user: `copmadinaarea_portal`
- Add user to database with ALL PRIVILEGES
2. **Upload Files**
- Via FTP, cPanel File Manager, or Git
- Upload ALL files including:
- `config/` folder
- `vendor/` folder (if exists)
- `.htaccess` file
- All PHP files
3. **Set Permissions**
```bash
chmod 755 -R application_folder/
chmod 777 uploads/
```
4. **Import Database**
- cPanel → phpMyAdmin
- Select your database
- Import → Choose SQL file
- Execute
5. **Run Diagnostic**
- Visit: `https://yourdomain.com/server_check.php`
- Check all green checkmarks
- Fix any red errors
6. **Test Application**
- Visit: `https://yourdomain.com/`
- Try login
- Check a module
7. **Secure & Clean Up**
- Delete `server_check.php`
- Delete `test_base_url.php`
- Verify all sensitive files are protected
---
## Quick Troubleshooting
### 500 Error Persists?
**1. Enable Error Display (Temporarily)**
Edit `config/config.php`, add at top:
```php
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
```
Reload page to see actual error message.
**2. Check .htaccess**
```bash
# Temporarily disable
mv .htaccess .htaccess.bak
# Test if site loads
# If yes, .htaccess is the problem
```
**3. Verify PHP Requirements**
```bash
# Create info.php:
<?php phpinfo(); ?>
# Visit it in browser
# Check PHP version and extensions
# DELETE after checking!
```
**4. Test Database Connection**
Visit `server_check.php` - Section 6 shows database status
**5. Check File Ownership**
Some servers require specific ownership:
```bash
# If you have SSH access:
chown -R username:username /path/to/app
```
---
## Platform-Specific Notes
### cPanel Hosting
- Use "Select PHP Version" to choose PHP 7.4+
- Use "PHP Extensions" to enable required extensions
- Database host is usually `localhost`
- Use File Manager or FTP for uploads
### DirectAdmin
- PHP Settings under "PHP Selector"
- Database via "MySQL Management"
- Upload via FTP or File Manager
### VPS/Dedicated Server
- Full control via SSH
- Install missing PHP extensions via apt/yum
- Configure Apache/Nginx as needed
- Set up cron jobs for email processing
### Shared Hosting
- May have restrictions on .htaccess directives
- Limited PHP configuration options
- Contact support if issues persist
---
## Production Optimizations
After deployment works:
1. **Disable Error Display**
```php
// config/config.php
ini_set('display_errors', 0);
error_reporting(0);
```
2. **Enable HTTPS**
- Get SSL certificate (Let's Encrypt via cPanel)
- Update BASE_URL auto-detection (already done)
3. **Set Up Cron Jobs**
```bash
# Email processing (every 5 minutes)
*/5 * * * * php /path/to/app/cron/process_emails.php
```
4. **Backup Setup**
- Enable automatic database backups
- Schedule file backups
- Test restore process
5. **Monitor Logs**
- Check error logs regularly
- Set up email alerts for critical errors
---
## Support Checklist
If asking for help, provide:
- [ ] PHP version (from server_check.php)
- [ ] Exact error message (from error logs)
- [ ] Server type (cPanel/VPS/shared)
- [ ] Results from server_check.php
- [ ] .htaccess contents
- [ ] Database connection test results
---
## Success Indicators
Application is working when:
- ✓ Homepage loads without errors
- ✓ Login works
- ✓ Dashboard displays
- ✓ Modules are accessible
- ✓ Database queries execute
- ✓ File uploads work
**Status:** Ready for deployment!
**Tools:** `server_check.php` for diagnostics
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists