In /etc/sysconfig/asterisk file changed to:
AST_USER=“asterisk”
AST_GROUP=“asterisk”
In /etc/asterisk/asterisk.conf file changed to:
runuser = asterisk ; The user to run as.
rungroup = asterisk ; The group to run as.
[files]
astctlpermissions = 0660
astctlowner = root
astctlgroup = apache
astctl = asterisk.ctl
And start Asterisk service like this:
systemctl start asterisk
systemctl status asterisk
● asterisk.service - LSB: Asterisk PBX
Loaded: loaded (/etc/rc.d/init.d/asterisk; bad; vendor preset: disabled)
Active: active (running) since Wed 2022-06-08 12:27:18 EDT; 2s ago
Docs: man:systemd-sysv-generator(8)
Process: 1643 ExecStart=/etc/rc.d/init.d/asterisk start (code=exited, status=0/SUCCESS)
Main PID: 1674 (asterisk)
CGroup: /system.slice/asterisk.service
├─1672 /bin/sh /usr/sbin/safe_asterisk
└─1674 /usr/sbin/asterisk -f -vvvg -c
Jun 08 12:27:18 xxx.xxx.xxx systemd[1]: Starting LSB: Asterisk PBX…
Jun 08 12:27:18 xxx.xxx.xxx asterisk[1643]: Starting asterisk:
Jun 08 12:27:18 xxx.xxx.xxx systemd[1]: Can’t open PID file /var/run/asterisk/asterisk.pid (yet?) after start: No such file or directory
Jun 08 12:27:18 xxx.xxx.xxx systemd[1]: asterisk.service: Supervising process 1674 which is not our child. We’ll most likely not notice when it exits.
Jun 08 12:27:18 xxx.xxx.xxx systemd[1]: Started LSB: Asterisk PBX.
In any case, the Asterisk service is started every time as the root user
~]# mount | grep -i tmp
devtmpfs on /dev type devtmpfs (rw,nosuid,size=1929732k,nr_inodes=482433,mode=755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
tmpfs on /run/user/0 type tmpfs (rw,nosuid,nodev,relatime,size=388016k,mode=700)
There is my /usr/lib/systemd/system/asterisk.service
[Unit]
Description=Asterisk PBX and telephony daemon.
After=network.target #include these if asterisk need to bind to a specific IP (other than 0.0.0.0)
#Wants=network-online.target
#After=network-online.target network.target
[Service]
Type=notify
Environment=HOME=/var/lib/asterisk #if systemd do not provide hostname and you need to use ${ENV(HOSTNAME)}
#Environment=HOSTNAME=%H
WorkingDirectory=/var/lib/asterisk
User=asterisk
Group=asterisk
ExecStart=/usr/sbin/asterisk -mqf -C /etc/asterisk/asterisk.conf
ExecReload=/usr/sbin/asterisk -rx ‘core reload’ #if /var/run is a tmpfs, this will create /var/run/asterisk on start
#RuntimeDirectory=asterisk
Name: asteriskcdrdb
DSN: MySQL-asteriskcdrdb
Last fail connection attempt: 2022-06-08 16:47:48
Number of active connections: 0 (out of 5)
Logging: Disabled
So there is a connection to the database or something needs to be corrected?
It says nothing regarding that. ps -el might tell you something.
It is desirable that it is not started as the asterisk user, as some things it may need to do when starting can only be run as root. It is better to use the asterisk configuration options to have it change.
Running it as asterisk is a security thing, but if you are running it on a dedicated machine, if asterisk gets compromised, you have lost the whole machine, anyway.
huu how is this system originally installed ?
via FreePBX image or by hand
for issues with installing and running FreePBX you should ask https://community.freepbx.org/