Synology NAS Deployment Guide

How to run the Centre Management System fully self-hosted on your DS418j

MariaDB 10 PHP 8.0 Apache 2.4 DSM 7.1.1

Steps in this guide

  1. Install required packages on DSM
  2. Enable MariaDB & create the database
  3. Run the SQL schema script
  4. Configure the PHP API credentials
  5. Upload application files to the NAS
  6. Enable Apache mod_rewrite
  7. Test & verify everything works
  8. Network access & remote access
  9. Troubleshooting
How the database layer works: The app's JavaScript calls fetch('tables/members') etc. Apache's .htaccess rewrites these to api.php, which talks to MariaDB. No code changes are needed in the HTML/JS files.
1

Install Required Packages

DSM Package Centre

Open DSM → Package Centre and install all three:

PackageVersionNotes
Apache HTTP Server 2.42.4.xWeb server — serves HTML/CSS/JS files
MariaDB 1010.xDatabase — stores all app data
PHP 8.08.0.xRuns api.php — bridges JS to MariaDB
Make sure to install PHP 8.0 (not PHP 7.x). In PHP settings, enable the PDO and PDO_MySQL extensions.

Enable PHP extensions in DSM:

  1. Go to Package Centre → PHP 8.0 → Open
  2. Click the PHP Settings tab (or open Web Station → PHP Settings)
  3. Enable: pdo, pdo_mysql, mysqli
  4. Click Apply
2

Enable MariaDB & Set Root Password

First-time setup
  1. Open DSM → MariaDB 10 from the main menu
  2. Click Enable MariaDB if not already running
  3. On the first launch, you will be prompted to set a root password — write it down!
  4. Note the port: Synology MariaDB 10 uses port 3307 by default (not the standard 3306)
The db/config.php file is already set to port 3307. If your NAS uses a different port, edit that file.
3

Run the SQL Schema Script

Creates the database, tables, triggers & app user

Option A — phpMyAdmin (Easiest)

  1. Install phpMyAdmin from DSM Package Centre (it's free)
  2. Open phpMyAdmin, log in with root and your root password
  3. Click the SQL tab at the top
  4. Open db/schema.sql from this project, copy the entire contents, paste into the SQL window
  5. Click Go / Execute
  6. You should see: "Schema installed successfully."

Option B — SSH Command Line

  1. Enable SSH on the NAS: DSM → Control Panel → Terminal & SNMP → Enable SSH
  2. SSH into the NAS from your PC:
    ssh admin@YOUR_NAS_IP
  3. Run the schema file:
    mysql -u root -p -P 3307 -h 127.0.0.1 < /volume1/web/centre/db/schema.sql
  4. Enter your root password when prompted
The schema creates a limited database user cms_user with password CHANGE_THIS_PASSWORD. You must change this password — see Step 4.
4

Configure Database Credentials

Edit db/config.php before uploading

Open db/config.php in a text editor and update the highlighted values:

define('DB_HOST',  'localhost');
define('DB_PORT',  3307);          // ← Synology MariaDB default
define('DB_NAME',  'centre_cms');
define('DB_USER',  'cms_user');    // ← the app-specific user
define('DB_PASS',  'YOUR_STRONG_PASSWORD'); // ← change this!

✏️  Choose a strong password for cms_user. Example:

DB_PASS: C3ntr3@NAS!2025

Then update the password in MariaDB too:

mysql -u root -p -P 3307 -h 127.0.0.1
ALTER USER 'cms_user'@'localhost' IDENTIFIED BY 'C3ntr3@NAS!2025';
FLUSH PRIVILEGES;
EXIT;
5

Upload Files to the NAS

Copy the project to Apache's web root

The web root for Apache on Synology is usually:

/volume1/web/

Create a centre/ subfolder and upload all project files maintaining this structure:

/volume1/web/centre/
├── index.html
├── manager.html
├── member.html
├── .htaccesscritical for URL routing
├── api.phpPHP REST API
├── css/
│ ├── shared.css
│ ├── manager.css
│ └── member.css
├── js/
│ ├── core.js
│ ├── manager.js
│ └── member.js
└── db/NOT web-accessible (.htaccess blocks it)
├── config.phpedit credentials here
├── .htaccessdenies web access to db/
└── schema.sql

Upload methods:

MethodHow
File StationDSM → File Station → navigate to web/ → drag and drop files
SFTPUse FileZilla or WinSCP, connect to NAS IP on port 22 with your DSM admin credentials
SSH + SCPscp -r ./centre/ admin@NAS_IP:/volume1/web/
6

Enable Apache mod_rewrite

Required for the .htaccess URL routing to work

The .htaccess file uses RewriteEngine. You need to confirm it's enabled.

Via SSH:

# Check if rewrite module is loaded
httpd -M 2>/dev/null | grep rewrite

# If not listed, enable it in Apache config:
# Edit /etc/httpd/conf/httpd.conf  (path may vary by DSM version)
# Uncomment or add:
LoadModule rewrite_module modules/mod_rewrite.so
On most Synology NAS with Apache 2.4 from Package Centre, mod_rewrite is already compiled in and active. If the .htaccess rules are ignored, enable AllowOverride All for the /volume1/web directory in the Apache config.

Verify AllowOverride in Apache config:

<Directory "/volume1/web">
    Options Indexes FollowSymLinks
    AllowOverride All    ← must be "All", not "None"
    Require all granted
</Directory>

Apache config is usually at: /etc/httpd/conf/httpd.conf or via DSM → Apache → Virtual Host settings

7

Test & Verify

Make sure everything is working
Use the built-in diagnostic tool first: Open http://NAS_IP/centre/api-test.php in your browser. It checks PHP extensions, the DB connection, all 7 tables, URL routing, and runs an API self-test automatically. Delete it once everything is confirmed working.
  • Run diagnostic: http://NAS_IP/centre/api-test.php — all rows should show green ✅
  • Open the app: http://NAS_IP/centre/ — you should see the portal selector
  • Test the API directly: http://NAS_IP/centre/tables/members should return {"data":[],"total":0,"page":1,"limit":100,"table":"members"}
  • Register a test member: Go to Manager Portal → New Registration, fill in and submit. The member should appear in the list.
  • Member login test: Open member.html, enter the test member's Membership ID and their PIN.
  • Check API in browser devtools: Open F12 → Network tab in manager.html, watch for tables/members calls returning 200.

Quick API smoke-test (SSH or browser):

# Test from NAS SSH:
curl -s http://localhost/centre/tables/facilities
# Expected: {"data":[],"total":0,...}

# Test member create:
curl -s -X POST http://localhost/centre/tables/members \
  -H "Content-Type: application/json" \
  -d '{"first_name":"Test","last_name":"Member","membership_id":"T0001","membership_type":"Adult","status":"Active","pin":"1234","emergency_name":"Test Emergency","emergency_phone":"12345678","phone":"91234567"}'
8

Network & Remote Access

LAN access + optional remote access
UserURLDevice
Manager (LAN)http://NAS_IP/centre/manager.htmlPC browser
Member (LAN WiFi)http://NAS_IP/centre/member.htmlMobile browser
Remote (HTTPS)https://yourname.synology.me/centre/Any

Enable HTTPS (recommended for remote access):

  1. Go to DSM → Control Panel → Security → Certificate
  2. Add a Let's Encrypt certificate for your Synology DDNS hostname
  3. Enable DDNS: Control Panel → External Access → DDNS → Add → choose Synology as provider → get yourname.synology.me
  4. Enable port forwarding on your router: external 443 → NAS IP:443
  5. Access remotely at https://yourname.synology.me/centre/

Troubleshooting

SymptomLikely CauseFix
Unsure what's wrong Unknown Open api-test.php — it shows exactly which component is failing
API returns 404 .htaccess rewrite not working Check AllowOverride All in Apache config; restart Apache after change
API returns 503 Database connection failed Wrong port / password / DB not running Check MariaDB is running in DSM; verify port 3307 and credentials in db/config.php
API returns 500 error PHP error Temporarily set DEBUG_MODE = true in db/config.php to see the error, then set back to false
PDO or pdo_mysql not found PHP extension not enabled Enable pdo + pdo_mysql in PHP 8.0 settings in DSM
db/config.php accessible via browser db/.htaccess not uploaded or AllowOverride off Upload db/.htaccess; ensure AllowOverride All is set
Members page empty after registering UUID() not supported in MariaDB version PHP api.php generates UUID in PHP — should work; check browser console for JS errors
App works locally but not remotely Router not forwarding port 80/443 Set up port forwarding: 80→NAS:80, 443→NAS:443 in your home router
WhatsApp links don't open WhatsApp Desktop not installed Install WhatsApp Desktop on manager's PC; links use wa.me which opens the desktop app

Useful SSH commands for debugging:

# Check Apache is running
synoservicectl --status pkgctl-Apache2.4

# Restart Apache
synoservicectl --restart pkgctl-Apache2.4

# Check MariaDB is running
synoservicectl --status pkgctl-MariaDB10

# Check Apache error log
tail -50 /var/log/apache2/error.log

# Check PHP error log
tail -50 /var/log/php8.0-fpm.log

# Test DB connection from CLI
mysql -u cms_user -p -P 3307 -h 127.0.0.1 centre_cms -e "SHOW TABLES;"

Deployment Summary

ComponentLocation on NAS
Web files (HTML/CSS/JS)/volume1/web/centre/
PHP API/volume1/web/centre/api.php
DB credentials (keep private)/volume1/web/centre/db/config.php
SQL schema (run once)/volume1/web/centre/db/schema.sql
DatabaseMariaDB 10 → database: centre_cms
Manager accesshttp://NAS_IP/centre/manager.html
Member accesshttp://NAS_IP/centre/member.html

Centre Management System · Synology NAS DS418j · DSM 7.1.1
← Return to Portal Home