AiPBX
Android testinə qoşul Xüsusiyyətlər Ekranlar Quraşdırma Mobil Sənədlər GitHub-da sponsor olun GitHub
Ana Səhifə / Documentation / System map (for administrators)

Texniki sənədlər yalnız ingilis dilindədir; GitHub və AiPBX portalındakı (Admin → Help) mətnlə eynidir.

System map (for administrators)

Where everything is on an installed AiPBX server and how to follow a problem from the portal to the file, process or log behind it. Everything here is on the server itself: it works without internet access. Paths are those of a standard install.sh installation; commands run as root (sudo).

Read it with Troubleshooting (symptom → fix) and Health (the automatic checks).

1. The big picture

 browser / app ──443──► nginx (TLS passthrough, picks by ALPN)
                         ├─ http/1.1, h2 ──► Apache 127.0.0.1:8443 (TLS)
                         │                   ├─ /            PHP portal (/opt/aipbx/web)
                         │                   ├─ /ws          Asterisk WebSocket 127.0.0.1:8088 (SIP for browsers/apps)
                         │                   ├─ /chat/ws     chat service 127.0.0.1:8086
                         │                   └─ /provision/  desk phone files (also over plain HTTP, port 80)
                         └─ no ALPN (TURNS) ──► coturn 5349 (media relay for WebRTC)
 desk phones ──5060 UDP/TCP, 5061 TLS──► Asterisk
 Asterisk ──AMI 127.0.0.1:5038──► portal (live state, originate, reload)
 Asterisk ──CURL / AudioSocket 127.0.0.1:8790/8791──► local AI service
 portal ──sudo──► /usr/local/sbin/aipbx-priv (the only root entry point)
 everything ──► MariaDB, database "asterisk"

Changes made in the portal are stored in the database first. Apply (top bar) writes the Asterisk files under /etc/asterisk/pbx/ and reloads Asterisk (section 5).

2. Source tree (/opt/aipbx)

/opt/aipbx is a git checkout of the release tag (cat /opt/aipbx/VERSION, git -C /opt/aipbx describe --tags). Updates replace it; do not edit files there by hand.

PathWhat it is
install.shInstalls and upgrades everything (--upgrade); the reference for what is put where
web/The portal (PHP), the API, cron/AGI scripts, translations
web/index.phpFront controller: every URL goes through it
web/src/routes.phpURL → controller map (one line per page)
web/src/controllers/One controller per page: access check, POST actions, rendering
web/src/services/Business logic (validation, saving, talking to Asterisk); most "why" comments live here
web/src/repositories/Database queries
web/src/sync/Generators of the Asterisk files (section 5)
web/templates/views/<page>/Page HTML; web/templates/layout*, sidebar_menu.php the frame and menu
web/assets/js/<page>.jsPage script; web/assets/css/ styles
web/api/JSON endpoints used by pages (/api/...) and the mobile apps (/api/mobile/...)
web/bin/Scripts run by cron, by Asterisk (System()/AGI) or by hand; symlinked into /usr/local/bin
web/lang/<code>.phpInterface texts, 23 languages (t('key') in PHP, __('js.key') in JS)
web/db/migrations/Database schema changes (Phinx), applied by install/update
web/auth.phpLogin session, role checks, page → permission module map (getModuleKeyForPage)
web/config.phpReads /etc/ai-pbx.env, database connection, t()
web/tests/PHPUnit tests (vendor/bin/phpunit), bin/smoke.php route/RBAC smoke test
chat/Chat service (Go), built to chat/aipbx-chat
ai/aipbx_ai/Local AI service (Python): models, voice requests, AudioSocket calls
conf/sbin/Root tools installed to /usr/local/sbin (section 8)
asterisk-config/Static Asterisk files installed once (the generated ones are in /etc/asterisk/pbx/)
sounds/Sound lists and helpers
android/, ios/Mobile apps (not used on the server)
docs/These documents (also shown in the portal: System → Help)

From a page to its code

Take the URL of the page (e.g. /phones) and follow:

  1. web/src/routes.php → '/phones' => PhoneController::index
  2. web/src/controllers/PhoneController.php → which service it calls (PhoneProvisionService)
  3. web/src/services/PhoneProvisionService.php → the logic; vendor files in web/src/services/phones/
  4. web/templates/views/phones/index.php → the HTML; web/assets/js/phones.js → the buttons' script
  5. Texts: search the shown text in web/lang/en.php to get its key, then the key in the code
  6. Who may open it: getModuleKeyForPage() in web/auth.php and System → Roles

grep -rn "something" /opt/aipbx/web/src finds the rest; error messages in the logs name the file and line.

3. Services

UnitWhatListensLogs
asteriskTelephony engine5060 udp/tcp, 5061 tls, 8088 (local, WebSocket), 5038 (local, AMI), RTP 10000–20000 udp/var/log/asterisk/messages.log, security.log; CLI asterisk -rvvv
apache2Portal, API, /ws and /chat/ws proxy127.0.0.1:8443 (TLS), 80/var/log/apache2/aipbx_ssl_error.log, aipbx_ssl_access.log
nginxPort 443 multiplexer (web vs TURNS)443/var/log/nginx/stream.log, error.log
mariadbDatabase asterisk127.0.0.1:3306journalctl -u mariadb
coturnTURN/TURNS relay for WebRTC media3478, 5349/var/log/turnserver/turnserver.log
aipbx-chatChat service (Go)127.0.0.1:8086journalctl -u aipbx-chat
aipbx-aiLocal AI models, voice requests, AudioSocket127.0.0.1:8790 (HTTP), 8791 (AudioSocket)journalctl -u aipbx-ai
postfixOutgoing mail (voicemail, fax, alerts)25 (local)journalctl -u postfix, mailq
fail2ban, firewalldBans, firewall–fail2ban-client status, firewall-cmd --list-all
chronyTime sync; NTP server for phones when switched on123 udpchronyc tracking, chronyc clients
aipbx-dnsmasqDHCP/TFTP for desk phones (Network services)67, 69 udpjournalctl -u aipbx-dnsmasq
aipbx-vsftpdRead-only FTP for desk phones21, 40000–40049/var/log/aipbx-ftp.log
aipbx-syslogPhone log receiver (Network & devices → Phone logs)514 udp/var/log/aipbx-phones/phones.log
aipbx-mdnsaipbx.local name on the LAN5353 udpjournalctl -u aipbx-mdns

systemctl status <unit> shows whether it runs; journalctl -u <unit> -n 100 its recent log. Units marked "when switched on" only run when the page enables them.

4. Files on the server

Configuration and secrets

PathWhat
/etc/ai-pbx.envDatabase users and passwords, AMI user, domain, paths. Read by the portal and scripts
/var/lib/aipbx/settings.keyKey that encrypts secrets stored in the database (SIP/trunk/API passwords, SecretBox)
/etc/aipbx/ai.tokenShared token between the portal and the local AI service
/etc/ssl/aipbx/active.crt, active.keyCertificate in use (copied to coturn and Asterisk by aipbx-cert)
/etc/asterisk/pbx/Files generated by Apply (section 5); *.prev = the previous version
/etc/asterisk/*.confAsterisk base files installed once (#include the pbx/ files)
/etc/apache2/sites-available/aipbx.conf, conf-available/aipbx-*.confWeb server site, routing, security headers
/etc/systemd/system/apache2.service.d/override.confLets the portal (and aipbx-priv through sudo) write /etc/asterisk and friends
/etc/nginx/aipbx-stream.confPort 443 multiplexer
/etc/turnserver.confcoturn
/etc/fail2ban/jail.d/*ai-pbx*, aipbx-web.localBan rules (portal page fail2ban)
/etc/sudoers.d/aipbxwww-data may run /usr/local/sbin/aipbx-priv only
/etc/cron.d/aipbxScheduled jobs (section 7)
/var/lib/aipbx-netsvc/DHCP/TFTP/FTP/syslog settings written by aipbx-priv netsvc

Never paste /etc/ai-pbx.env or settings.key into a ticket: they hold every secret. Losing settings.key makes the encrypted passwords in the database unreadable; it is in the backups.

Data

PathWhat
/var/spool/asterisk/monitor/Call recordings
/var/spool/asterisk/voicemail/Voicemail
/var/spool/asterisk/fax/Faxes (incoming, outgoing/)
/var/lib/asterisk/sounds/Prompts (tr/, custom/), /var/lib/asterisk/moh/ music on hold
/var/lib/aipbx/chat_files/Chat attachments (when not on S3)
/var/lib/aipbx/tftp/TFTP/FTP folder for desk phones
/var/lib/aipbx/tts/Generated speech
/var/lib/aipbx-ai/Local AI models and app configs
/var/backups/aipbx-daily/Daily backup (aipbx-backup)
/var/backups/aipbx/Backup taken before each update (aipbx-update)

Logs

PathWhat
/var/log/asterisk/messages.logCalls, SIP, dialplan; first stop for "call does not work"
/var/log/asterisk/security.logFailed SIP logins (fail2ban reads it)
/var/log/apache2/aipbx_ssl_error.logPHP errors and warnings of the portal
/var/log/apache2/aipbx_ssl_access.logEvery web/API request (a WebSocket line is written when it closes)
/var/log/aipbx/update.logUpdates; backup.log backups; web_login_failures.log failed portal logins
/var/log/fax_incoming.log, fax_outgoing.logFax processing
/var/log/aipbx-phones/phones.logDesk phone syslog (Network & devices → Phone logs)
/var/log/aipbx-ftp.logFTP transfers of desk phones
journalctl -t aipbx-voicemailVoicemail notifications (push, mail)
Portal: Security → Audit logWho changed what in the portal, and Apply errors

5. Apply: from the database to Asterisk

  1. A page saves to the database and marks its area as pending (sys_pending_sync).
  2. Apply (or php /opt/aipbx/web/src/asterisk_sync.php, which regenerates everything) runs the generators in web/src/sync/, writes each file atomically, keeps the previous one as .prev, and reloads only the Asterisk modules concerned. Calls are not dropped.
  3. If a file cannot be written or Asterisk rejects it, the previous file is restored, the area stays pending and the error is shown and audit-logged.
Generator (web/src/sync/)File in /etc/asterisk/pbx/
SyncExtensionspjsip_endpoints.conf (users' desk phone, WebRTC and mobile endpoints)
SyncTrunkspjsip_trunks.conf
SyncTransportspjsip_transports.conf (ports, NAT addresses, TLS)
SyncInboundDialplanextensions_inbound.conf (inbound routes, DIDs)
SyncOutboundDialplanextensions_outbound.conf
SyncPermissionsextensions_permissions.conf (dial permissions)
SyncGeneralDialplanextensions_general.conf (internal dialling, voicemail, common contexts)
SyncInternalNumbersextensions_internalnumbers.conf
SyncFeatureCodesextensions_featurecodes.conf
SyncIVRs, SyncTimeConditionsextensions_ivrs.conf (time conditions are part of it)
SyncRingGroupsextensions_ringgroups.conf
SyncQueuesqueues_pbx.conf
SyncConferencesextensions_conferences.conf
SyncAiAppsextensions_ai_apps.conf
SyncWidgetsextensions_widgets.conf, pjsip_widgets.conf
SyncVoicemailvoicemail_general.conf, voicemail_pbx.conf
SyncMOHmusiconhold_pbx.conf
SyncRtpSettings, SyncUdptlSettingsrtp.conf, udptl.conf

To see what changed: diff /etc/asterisk/pbx/<file>.prev /etc/asterisk/pbx/<file>.

6. Database (asterisk)

mysql asterisk as root opens it. Main tables by area:

TablesWhat
sys_users, sys_roles, sys_role_permissionsUsers (extensions are users), roles, permissions
sys_settingsMost portal settings (key/value)
sys_pending_syncAreas waiting for Apply
sys_audit_log, sys_login_logsAudit log, logins
sys_mobile_devicesSigned-in mobile apps and their push tokens
pbx_trunks, pbx_dids, pbx_outbound_routes, pbx_permission_*Trunks and routing
pbx_ivrs, pbx_ivr_entries, pbx_time_*, pbx_ring_groups, pbx_queues, pbx_conferencesCall flow
pbx_phones, pbx_phones_waiting, pbx_phone_keys, pbx_phone_fetch_logDesk phone provisioning
pbx_ai_apps, ai_requests, ai_cloud_usage, ai_tts_history, voicemail_aiAI
asteriskcdr, asteriskcel, cdrsCall records (Asterisk CDR/CEL, portal call list)
asteriskqueue, cc_queue_logs, cc_pause_logs, queues_detailsCall center
chat_*Chat
fax_received, fax_sentFax
health_checks, health_eventsHealth page
phinx_migrationsApplied schema migrations

7. Scheduled jobs (/etc/cron.d/aipbx)

WhenJobWhat
every minuteaipbx_health.phpHealth checks; mails the admin when something breaks
every minutesync_queue_logs.phpQueue log into cc_queue_logs
every minutefax_pending_sweep.shFinishes faxes Asterisk left pending
every 5 minrecordings_to_mp3.phpConverts recordings
every 5 minfax_to_bucket.php, hourly voicemail_to_bucket.phpCopies to S3 storage when configured
every 5 minprovision_tftp.php (www-data)Writes desk phone files into the TFTP/FTP folder when that option is on
02:30aipbx-backupDaily backup
03:15fax_cleanup.shRemoves old fax files
04:37aipbx-update --checkLooks for a new release (does not install it)

8. Root tools (/usr/local/sbin)

ToolWhat
aipbx-selftestRuns every health check now and prints OK/FAIL with the reason. Start here
aipbx-update [--yes] [--check]Updates to the latest release: backup, git checkout, install.sh --upgrade, migrations; rolls back by itself on failure. Restarts Asterisk (drops calls)
aipbx-backupDatabase and configuration backup to /var/backups/aipbx-daily
aipbx-certCertificate handling (self-signed, Let's Encrypt, uploaded)
aipbx-privThe portal's only way to root: fixed subcommands with validated arguments (service, postfix, fw, f2b, cert, update, sounds, asterisk-lang, netsvc, net, ai). Read it to see exactly what a page may do as root
aipbx-readdress <old> <new> [--yes]Moves every setting and file from the old server address to the new one (preview first); same as Network settings → Apply new address
aipbx-soundsDownloads and installs sound packs
aipbx-ai-setupInstalls or removes the local AI runtime
aipbx-dhcp-probe <iface>Lists DHCP servers answering on a network
aipbx-syslogdThe phone log receiver (run by aipbx-syslog)

9. Debugging recipes

Start with aipbx-selftest and the portal's Health page; most broken services show there.

A page shows an error or a blank part

  1. tail -f /var/log/apache2/aipbx_ssl_error.log and reload the page: the PHP error names file and line.
  2. Browser developer tools → Console/Network: a failing /api/... call shows its JSON error.
  3. Follow the page to its code (section 2).

Apply fails or a change does nothing

  1. The error is shown on Apply and kept in Security → Audit log.
  2. php /opt/aipbx/web/src/asterisk_sync.php regenerates everything and prints errors.
  3. asterisk -rx "dialplan reload" / asterisk -rx "module reload res_pjsip.so" and check messages.log for syntax errors in /etc/asterisk/pbx/.

A call fails

  1. asterisk -rvvv, make the call, read the dialplan steps (Executing [...]).
  2. asterisk -rx "pjsip show contacts" — is the phone or trunk registered/reachable?
  3. asterisk -rx "pjsip set logger on" (off again afterwards) shows the SIP messages; or capture: see Troubleshooting → Capturing SIP.
  4. Call records: portal Reports, or SELECT * FROM asteriskcdr ORDER BY calldate DESC LIMIT 20;.

Browser or mobile app does not ring / no audio

  1. asterisk -rx "pjsip show contacts" | grep webrtc — mobile endpoints are <ext>-mob-webrtc.
  2. /var/log/apache2/aipbx_ssl_access.log: GET /ws with 101 = WebSocket opened (logged when it closes); 503 = Asterisk was not reachable at that moment.
  3. Audio: WebRTC, NAT and TURN; /var/log/turnserver/turnserver.log.
  4. App push and background: Troubleshooting → notifications.

Desk phone does not get its configuration

  1. Network & devices → Phones: Show the phone's file shows exactly what it gets; Network settings shows the addresses the phones are told.
  2. Network & devices → Phone logs: one tab each for the phone's own log (syslog), HTTPS, FTP, TFTP and DHCP, by IP or MAC.
  3. On the server: journalctl -u aipbx-dnsmasq, /var/log/aipbx-ftp.log, files in /var/lib/aipbx/tftp.

Mail is not sent

mailq (queue), journalctl -u postfix -n 50; settings: System → Mail settings.

Fax

/var/log/fax_incoming.log, /var/log/fax_outgoing.log, asterisk -rx "fax show sessions".

Chat or AI

journalctl -u aipbx-chat -n 100, journalctl -u aipbx-ai -n 100; curl -s http://127.0.0.1:8790/v1/health for the AI service.

Login problems

/var/log/aipbx/web_login_failures.log; fail2ban-client status aipbx-web (banned addresses).

Time

chronyc tracking; phones: chronyc clients (when NTP server is on).

10. Where is …? (feature → code)

FeatureStart at
Extensions / usersExtensionController, SystemUserController, web/src/sync/SyncExtensions.php
TrunksTrunkController, SyncTrunks.php
Inbound / outbound routesDidRouteController, OutboundRouteController, SyncInboundDialplan.php, SyncOutboundDialplan.php
IVR, time conditionsIvrController, TimeConditionController, SyncIVRs.php, SyncTimeConditions.php
Queues, call centerQueueController, CcAgentController, CcSupervisorController, web/src/queue_helper.php
Desk phonesPhoneController, PhoneProvisionService, web/src/services/phones/<Vendor>Template.php, ProvisionController (/provision/)
Network settings, address changeNetworkSettingsController, NetworkSettingsService, aipbx-priv net, web/bin/readdress.php
Network services, phone logsNetworkServicesService, PhoneLogService, aipbx-priv netsvc
Web phone (browser)MyPhoneController, web/assets/js/header_phone.js (top bar phone), my_phone.js
Mobile app APIweb/api/mobile/
Push notificationsweb/src/services/push/, web/bin/push_dispatcher.php
VoicemailSyncVoicemail.php, web/bin/voicemail_notify.php, voicemail_mail.php
FaxFax*Controller, web/bin/process_incoming_fax.sh, process_outgoing_fax_result.sh
Chatchat/ (Go), ChatController
Local AI, voice requestsai/aipbx_ai/, AiModelsController, AiAppsController, SyncAiApps.php
Cloud AI / TTSAiCloudController, AiTtsController, web/src/services/ai/
Health checksweb/src/services/health/HealthChecks.php, conf/sbin/aipbx-selftest
Updates, backupsconf/sbin/aipbx-update, aipbx-backup, SystemUpdateController
Certificatesconf/sbin/aipbx-cert, CertificateController
Roles and permissionsRoleController, web/auth.php
Translationsweb/lang/, Translating

View or edit this page on GitHub

On This Page