I have just compiled asterisk using --prefix=/opt/asterisk and --exec-prefix=/opt/asterisk. It compiles OK and runs from command line or in the background.
However having started asterisk in the background a command of asterisk -r fails Unable to connect, does asterisk.ctl exist.
I’ve tracked this down to the fact that the default for asrundir in the asterisk.config sample is set to /var/run/asterisk but the safe_asterisk script has ASTVARRUNDIR=/opt/asterisk/var/run/asterisk.
So we have two different locations for the runtime directory.
I know I can modify either of these variables in their respective files but I don’t understand why the safe script has added the prefix to the rundir and also to the logdir.