WHMCS Affiliate Portal ��� Installation Manual

WHMCS Affiliate Portal — Installation Manual

Version 1.0.0 · Works on cPanel, DirectAdmin, Plesk, Ubuntu VPS and AlmaLinux · Apache or Nginx


1. Requirements

Item Requirement
PHP 8.2 or newer
PHP extensions pdo, pdo_mysql, json, openssl, curl, fileinfo, mbstring, tokenizer, xml, zip, session
Database MySQL 8.0+ (MariaDB 10.4+ also works)
Web server Apache 2.4 (mod_rewrite) or Nginx
HTTPS Strongly recommended — required for production logins
Writable folders storage/ (and sub-folders) and config/

The wizard checks all of this for you in step 2.

2. Quick install (8 steps)

  1. Upload the ZIP to the subdomain folder (e.g. affiliate.example.com) and extract it.
  2. Create a MySQL database and user (section 4).
  3. Open https://affiliate.example.com/install.
  4. Follow the wizard: Requirements → Database → Administrator → Portal settings → WHMCS API → Install → Cron → Finish.
  5. Create the first administrator (you choose the password; there are no default credentials).
  6. Enter WHMCS API credentials (or skip and do it later at Admin → WHMCS).
  7. Add the cron job (section 8).
  8. Finish. The installer locks itself. /install now shows Application Already Installed.

Do the install right after uploading. Until installation finishes, anyone who can reach /install could run the wizard.

3. Choosing the document root

Recommended (most secure): set the subdomain document root to the public/ folder. Then app/, config/, database/, storage/, install/ and cron/ are not inside the web root at all.

Also supported: keep the document root at the extracted folder. The supplied root .htaccess blocks every private folder and routes requests to public/. This requires Apache with AllowOverride enabled (default on cPanel, DirectAdmin and Plesk). The installer’s Private files protected check confirms it works.

4. Create the MySQL database

cPanel: MySQL® Database Wizard → create database → create user with a strong password → tick ALL PRIVILEGES. Note that names are prefixed (account_dbname, account_dbuser).

DirectAdmin: MySQL Management → Create new Database, enter name, user and password.

Plesk: Databases → Add Database, then create a database user with full access to it.

Ubuntu / AlmaLinux (command line):

CREATE DATABASE affiliate CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'affiliate'@'localhost' IDENTIFIED BY 'CHOOSE_A_STRONG_PASSWORD';
GRANT ALL PRIVILEGES ON affiliate.* TO 'affiliate'@'localhost';
FLUSH PRIVILEGES;

Use host localhost, port 3306, and keep the default prefix aff_ in the wizard.

5. File permissions

Path Permission
folders 755 (or 775 if your host requires group write)
files 644
storage/ and sub-folders writable by the PHP user (755/775)
config/ writable during install; config/config.php is written as 640
cd /var/www/affiliate
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
chown -R www-data:www-data storage config      # Ubuntu; use apache:apache on AlmaLinux

On cPanel/DirectAdmin/Plesk PHP already runs as your account user, so no chown is needed.

After installation you may tighten config/ to read-only: chmod 555 config.

6. Web server configuration

Apache

Nothing to do: .htaccess files are included (root, public/, and a deny-all in every private folder). Make sure mod_rewrite is enabled and AllowOverride All is set for the site on a VPS:

<VirtualHost *:443>
    ServerName affiliate.example.com
    DocumentRoot /var/www/affiliate/public
    <Directory /var/www/affiliate/public>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Nginx

Use docs/nginx.conf.example (document root = public/, PHP-FPM, deny rules, security headers). After editing, run nginx -t && systemctl reload nginx.

Nginx ignores .htaccess, so do not use the project root as the document root on Nginx.

7. SSL (HTTPS)

8. Cron job

The portal needs one job, every 5 minutes, running cron/run.php. The wizard (step 8) shows the exact command for your server. The format is:

*/5 * * * * /usr/bin/php /path/to/affiliate/cron/run.php >/dev/null 2>&1

Cron is reported as running only after the script has really executed: each run records a heartbeat, and the installer’s Check cron status button and the admin dashboard read it. Until then they show Not verified.

9. WHMCS API setup

In WHMCS: Setup → Staff Management → Manage API Credentials → Generate New API Credential. Create an API Role allowing at least: GetClients, GetClientsProducts, GetClientsDomains, GetInvoices, GetProducts.

If WHMCS uses API IP Access Restriction (Setup → General Settings → Security), add the public IP of the affiliate portal server. The wizard’s test reports the exact IP WHMCS rejected. Alternatively use an API Access Key.

The WHMCS URL must be the public address of WHMCS (private/internal addresses are refused for safety; set the environment variable AFFILIATE_ALLOW_PRIVATE_URLS=1 if WHMCS is genuinely on a private network).

The API secret is stored encrypted (AES-256-GCM) in the database; the key lives only in config/config.php.

You can skip this step and configure everything later at https://affiliate.example.com/admin/whmcs.

10. After installation

Logs

storage/logs/installer.log (installer), storage/logs/cron.log, storage/logs/app.log. Secrets are redacted before being written. These folders are blocked from web access.

11. Troubleshooting

Message Fix
Unsupported PHP version Switch to PHP 8.2+ in the hosting panel
Missing extension Enable it (cPanel Select PHP Version → Extensions; Ubuntu apt install php8.2-<ext>)
Not writable Fix permissions (section 5)
Invalid database credentials Use the prefixed username shown in your panel; re-enter the password
Database not found Create the database first
Insufficient privileges Grant ALL PRIVILEGES to the user on that database
Existing installation detected The database already contains a finished install. Use an empty database or another prefix
SQL migration failed Read storage/logs/installer.log, fix the cause, press Retry — finished migrations are skipped, nothing is duplicated
Configuration could not be written Make config/ writable and retry
WHMCS: Invalid IP Whitelist the portal server IP in WHMCS
WHMCS: Authentication failed Check Identifier/Secret; make sure the credential is enabled
storage/ publicly readable warning Point the document root to public/, or add the Nginx deny rules
404 on /install (Apache) mod_rewrite / AllowOverride is disabled

12. Deliberate reinstall (administrators only)

There is no web option to reinstall. Over SSH, as the account that owns the files:

mysqldump -u USER -p DATABASE > backup.sql     # always back up first
php bin/reinstall.php

The tool requires typing YES and then REINSTALL <database name>. It drops every table with the configured prefix, backs up and removes config/config.php, and removes the lock so /install works again.

13. Package layout

public/        web root (front controller, assets, help)
install/       installer (private; reached only through /install)
app/           application code
config/        config.example.php (+ generated config.php)
database/      migrations/ and seeds/
storage/       installer.lock, logs/, sessions/, cache/, uploads/, backups/
cron/          run.php
bin/           reinstall.php
docs/          this manual, nginx.conf.example

14. Security summary