Init script


I can download, compile, config and run Asterisk from the CentOS 6.4 console. However, when I try to start it as service using “service asterisk start” it does not work. Following some other forum threads, on my install I am also doing:

adduser -c “asterisk” -r -s /bin/false asterisk

chown -R asterisk:asterisk /usr/lib/asterisk/
chown -R asterisk:asterisk /var/lib/asterisk/
chown -R asterisk:asterisk /var/spool/asterisk/
chown -R asterisk:asterisk /var/log/asterisk/
chown -R asterisk:asterisk /var/run/asterisk/
chown -R asterisk:asterisk /usr/sbin/asterisk
chown -R asterisk:asterisk /etc/asterisk

On asterisk.conf I have:
runuser = asterisk
rungroup = asterisk

Any hint on how I can get the init script to get working?


Hi Mo, Are you getting an error? and what version of asterisk are you running?

I am using Asterisk 11. When I try to start the service via init script it says “Starting Asterisk…”, but then nothing happens after this. It must be something stupid I am doing (or not doing :blush: ).

I will do some checks about who is running it as I have set asterisk.conf to run Asterisk as user “asterisk” but I never checked, when I invoke it from the console, if it runs as “root” or asterisk user. This might be the problem… But the reality is that you download, compile, make config, make install, make the samples and, when you try to start it using “service start asterisk”, it doesn’t start.

I had a similar issue with asterisk 11 on centos 6.4 a few weeks (or months) back, “ldconfig” needed to be run after asterisk compilation/installation. Can you try that and see? Also, I presume you can start asterisk without the startup scripts? can you confirm


Yes, I can start Asterisk running “asterisk -cvvv”. It will fail to start if you don’t issue a “ldconfig” after compiling/installing. If you don’t do it, it will fail looking for “”. But if you don’t do a “ldconfig”, you can still start it if you do a “export LD_LIBRARY_PATH=/usr/lib” (in my case I compile it using “./configure --prefix=/usr”).

So, I think the install script should include a “ldconfig”. But anyway, the init script does not work even if you do a make, make install, make config and make samples. But as I said, I am not sure if the init is failing because the asterisk user I create does not have the necessary rights to do what is necessary. So any hint is more than welcome! But I guess I am not “unique” so more people had (or are having) the same problem.


On normal Linux and Unix systems, /usr/lib is on the default LD_LIBRARYPATH.

Sorry David but what is “normal”? I think my install is quite “normal”, I think… What I do is:
1 - I install CentOS 6.4 from minimal install ISO.

2 - As soon as I get it installed, I disable postfix, selinux, iptables, update and then reboot the system:

chkconfig postfix off
chkconfig iptables off
sed -i ‘s|SELINUX=enforce|SELINUX=disable|’ /etc/selinux/config
yum update -y && reboot

3 - After this I install all dependencies:

yum install gcc.x86_64 gcc-c++.x86_64 ntp
make.x86_64 wget.x86_64 subversion.x86_64
libxml2-devel.x86_64 ncurses-devel.x86_64
openssl-devel.x86_64 sqlite-devel libpcap -y

4 - Then I fix the time:

chkconfig ntpd on
service ntpd start

5 - Get the code and compile it:

svn checkout asterisk
cd /usr/local/src/asterisk
./configure --prefix=/usr
make install
make config
make samples

6 - As it will not work, I do:

That is it! Now, what am I doing wrong? I “think” I should be able to issue a “service aterisk start” and it should start Asterisk with the “sample” configuration. But it doesn’t.

Anyway, I know it is quite difficult to adapt the code for all Linux flavors. However, what I want to find is what I should do, that is missing, to get it working from the init script. That is it!



CentOS 5.7, Debian Wheezy, Slackware 14, SCO OpenServer, SunOS, the Zilog Unix I used, over thirty years ago, are normal. I have no experience of CentOS 6, but I can’t think of any good reason why they would stop using /usr/lib.

The reason it might need ldconfig would be that there was a previous library, of the same name, in a different place. The loader should search the default LD_LIBRARYPATH if there was no entry in the cache and the default LD_LIBRARYPATH should include /usr/lib.

If anything, what the LD_LIBRARYPATH issues suggests is that there is a library on the default LD_LIBRARYPATH that is unusable, but of the right name, so by eliminating the other directories on the default path, you are invalidating the cache entries for them.

In terms of the history of Unix, ldconfig and the shared object cache is relatively recent, compared with the use of /usr/lib.

Well… Some more info. I am using the following when I finish installing:

Fix the problem with the library


Make Asterisk run as asterisk user

adduser -c “asterisk” -r -s /bin/false asterisk
sed -i ‘s|;runuser|runuser|’ /etc/asterisk/asterisk.conf
sed -i ‘s|;rungroup|rungroup|’ /etc/asterisk/asterisk.conf

Change necessary file permissions

chown -R asterisk:asterisk /usr/lib/asterisk/
chown -R asterisk:asterisk /var/lib/asterisk/
chown -R asterisk:asterisk /var/spool/asterisk/
chown -R asterisk:asterisk /var/log/asterisk/
chown -R asterisk:asterisk /var/run/asterisk/
chown -R asterisk:asterisk /usr/sbin/asterisk


Now, if I start Asterisk issuing “asterisk -U asterisk -G asterisk -cvvvvv”, it works. However, when I try “service asterisk start” and then I do a “service asterisk status” I get: “asterisk dead but subsys locked”.

When I try to stop it, I get:

service asterisk stop
Stopping safe_asterisk: [ OK ]
Shutting down asterisk: [FAILED]

Now I am locked! I get no clue from where I should start to fix it.

Just for anyone looking to troubleshoot similar problems, there are a few things going on that really shut Asterisk up and hide important debugging information. In my case safe_asterisk was starting up, but nothing else happened. Not a single byte of logging, so I had to get it making some noise.

First, in /etc/init.d/asterisk you can edit this line:

Remove the redirection to get some error messages:

If that doesn’t do the trick, you can also prevent Asterisk from outputting to TTY9 by commenting out this line in /usr/sbin/safe_asterisk:

By using these two methods I was able to figure out two problems that were tripping Asterisk up (missing PID file and typo in the asterisk.conf runuser.)

Hey! Got the answer, now over two years later… just posting this for posterity.

This answer was originally provided by Russell Bryant on another forum. If you’re running 64-bit CentOS 6.x (and maybe others), libasteriskssl should be installed into /usr/lib64. If you’re installing from source, Asterisk will install it to /usr/lib/ by default, which is wrong. To fix it, you must add an option when running configure: