How to run the Centre Management System fully self-hosted on your DS418j
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.Open DSM → Package Centre and install all three:
| Package | Version | Notes |
|---|---|---|
| Apache HTTP Server 2.4 | 2.4.x | Web server — serves HTML/CSS/JS files |
| MariaDB 10 | 10.x | Database — stores all app data |
| PHP 8.0 | 8.0.x | Runs api.php — bridges JS to MariaDB |
pdo, pdo_mysql, mysqlidb/config.php file is already set to port 3307. If your NAS uses a different port, edit that file.root and your root passworddb/schema.sql from this project, copy the entire contents, paste into the SQL windowssh admin@YOUR_NAS_IP
mysql -u root -p -P 3307 -h 127.0.0.1 < /volume1/web/centre/db/schema.sql
cms_user with password CHANGE_THIS_PASSWORD. You must change this password — see Step 4.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;
The web root for Apache on Synology is usually:
/volume1/web/
Create a centre/ subfolder and upload all project files maintaining this structure:
| Method | How |
|---|---|
| File Station | DSM → File Station → navigate to web/ → drag and drop files |
| SFTP | Use FileZilla or WinSCP, connect to NAS IP on port 22 with your DSM admin credentials |
| SSH + SCP | scp -r ./centre/ admin@NAS_IP:/volume1/web/ |
The .htaccess file uses RewriteEngine. You need to confirm it's enabled.
# 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
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.<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
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.http://NAS_IP/centre/api-test.php — all rows should show green ✅http://NAS_IP/centre/ — you should see the portal selectorhttp://NAS_IP/centre/tables/members should return {"data":[],"total":0,"page":1,"limit":100,"table":"members"}member.html, enter the test member's Membership ID and their PIN.tables/members calls returning 200.# 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"}'
| User | URL | Device |
|---|---|---|
| Manager (LAN) | http://NAS_IP/centre/manager.html | PC browser |
| Member (LAN WiFi) | http://NAS_IP/centre/member.html | Mobile browser |
| Remote (HTTPS) | https://yourname.synology.me/centre/ | Any |
yourname.synology.mehttps://yourname.synology.me/centre/| Symptom | Likely Cause | Fix |
|---|---|---|
| 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 |
# 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;"
| Component | Location 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 |
| Database | MariaDB 10 → database: centre_cms |
| Manager access | http://NAS_IP/centre/manager.html |
| Member access | http://NAS_IP/centre/member.html |
Centre Management System · Synology NAS DS418j · DSM 7.1.1
← Return to Portal Home