**Prerequisites:**

- PHP 8.0+ with required extensions (gd, curl, zip, mbstring)
- MySQL or MariaDB
- SSH or SFTP access to your server
- A DeployHQ account

## What is OpenCart?

OpenCart is a free, open-source PHP e-commerce platform. It's file-based and straightforward — no Composer, no build tools, no Node.js required for the default installation. This makes it ideal for SFTP-based deployment.

OpenCart powers over 400,000 online stores and is popular with merchants who want a simple, self-hosted e-commerce solution.

## Project Structure

```
opencart/
├── admin/               # Admin panel
│   ├── controller/
│   ├── model/
│   ├── view/
│   └── index.php
├── catalog/             # Storefront
│   ├── controller/
│   ├── model/
│   ├── view/
│   └── language/
├── image/               # Product images and assets
│   ├── cache/           # ⚠️ Exclude from deployment
│   └── catalog/         # Product images
├── system/              # Core framework
│   ├── config/
│   ├── library/
│   └── storage/         # ⚠️ Exclude from deployment
├── config.php           # ⚠️ Environment-specific, exclude
├── admin/config.php     # ⚠️ Environment-specific, exclude
└── .htaccess
```

## Version Control Setup

**.gitignore:**
```gitignore
config.php
admin/config.php
image/cache/
system/storage/
```

These files are environment-specific or generated. They should not be in Git or deployed.

## Deploy with DeployHQ

### Server Configuration

- **Protocol:** SSH or SFTP
- **Deployment Path:** `/var/www/html/` (or your web root)
- **Excluded Files:** `config.php`, `admin/config.php`

### No Build Commands Needed

OpenCart is pure PHP — no compilation or bundling required. Files are deployed as-is.

### Shared Paths (Zero-Downtime Mode)

If using zero-downtime deployments:
- `config.php` — database credentials and paths
- `admin/config.php` — admin configuration
- `image/catalog/` — product images uploaded by merchants
- `system/storage/` — cache, logs, sessions

### Post-Deployment

Clear OpenCart's cache after deployment:
```bash
rm -rf /var/www/html/system/storage/cache/*
```

### Extension and Theme Deployment

Custom OpenCart themes live in:
```
catalog/view/theme/my-theme/
```

Custom extensions follow the OCMOD or VQMod pattern. Deploy extension files to their respective directories — OpenCart's modification system handles the rest.

## Troubleshooting

### File Permission Issues

OpenCart requires write access to specific directories:
```bash
chmod 755 image/ image/cache/ image/catalog/ system/storage/
```

### Modification System (OCMOD)

After deploying new OCMOD extensions, refresh modifications in admin:
**Extensions** → **Modifications** → **Refresh**

Or via CLI if available:
```bash
php /var/www/html/system/storage/vendor/bin/ocmod refresh
```

### Configuration Mismatch

If `config.php` paths don't match the deployment directory, OpenCart will show errors. Ensure the config files on the server reference the correct paths.

## Conclusion

OpenCart's file-based architecture makes it a natural fit for SFTP deployment. No build tools, no package managers — just PHP files deployed to your server.

[Sign up for DeployHQ](https://www.deployhq.com/signup) — free for one project.

Questions? Contact [support@deployhq.com](mailto:support@deployhq.com) or on [Twitter/X](https://x.com/deployhq).
