# Init script

**URL:** <https://community.asterisk.org/t/init-script/44503>\
**Category:** Asterisk Support\
**Created:** [November 18, 2013, 7:58pm UTC](https://community.asterisk.org/t/init-script/44503 "2013-11-18T19:58:44Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![moferreira](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@moferreira](https://community.asterisk.org/u/moferreira)\
**Post date:** [November 18, 2013, 7:58pm UTC](https://community.asterisk.org/t/init-script/44503/1 "2013-11-18T19:58:44Z")

</div>

Hi,

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:  
[options]  
runuser = asterisk  
rungroup = asterisk

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

Mo

---

<div class="post-metadata">

**Author:** ![wallnutmonkeys](https://avatars.discourse-cdn.com/v4/letter/w/ba9def/32.png) [@wallnutmonkeys](https://community.asterisk.org/u/wallnutmonkeys)\
**Post date:** [November 19, 2013, 2:42pm UTC](https://community.asterisk.org/t/init-script/44503/2 "2013-11-19T14:42:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![moferreira](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@moferreira](https://community.asterisk.org/u/moferreira)\
**Post date:** [November 20, 2013, 6:55pm UTC](https://community.asterisk.org/t/init-script/44503/3 "2013-11-20T18:55:33Z")

</div>

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 😊 ).

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.

---

<div class="post-metadata">

**Author:** ![wallnutmonkeys](https://avatars.discourse-cdn.com/v4/letter/w/ba9def/32.png) [@wallnutmonkeys](https://community.asterisk.org/u/wallnutmonkeys)\
**Post date:** [November 20, 2013, 7:14pm UTC](https://community.asterisk.org/t/init-script/44503/4 "2013-11-20T19:14:22Z")

</div>

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

cheers  
wallnut

---

<div class="post-metadata">

**Author:** ![moferreira](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@moferreira](https://community.asterisk.org/u/moferreira)\
**Post date:** [November 21, 2013, 9:29pm UTC](https://community.asterisk.org/t/init-script/44503/5 "2013-11-21T21:29:53Z")

</div>

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 “libasteriskssl.so.1”. 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.

Cheers!

---

<div class="post-metadata">

**Author:** ![david55](https://avatars.discourse-cdn.com/v4/letter/d/e19adc/32.png) [@david55](https://community.asterisk.org/u/david55)\
**Post date:** [November 21, 2013, 9:59pm UTC](https://community.asterisk.org/t/init-script/44503/6 "2013-11-21T21:59:21Z")

</div>

On normal Linux and Unix systems, /usr/lib is on the default LD\_LIBRARYPATH.

---

<div class="post-metadata">

**Author:** ![moferreira](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@moferreira](https://community.asterisk.org/u/moferreira)\
**Post date:** [November 22, 2013, 10:09pm UTC](https://community.asterisk.org/t/init-script/44503/7 "2013-11-22T22:09:09Z")

</div>

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:

ntpdate [pool.ntp.org](http://pool.ntp.org)  
chkconfig ntpd on  
service ntpd start

5 - Get the code and compile it:

svn checkout [svn.asterisk.org/svn/asterisk/branches/11](http://svn.asterisk.org/svn/asterisk/branches/11) asterisk  
cd /usr/local/src/asterisk  
./configure --prefix=/usr  
make  
make install  
make config  
make samples

6 - As it will not work, I do:  
ldconfig

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!

Cheers!

Mo

---

<div class="post-metadata">

**Author:** ![david55](https://avatars.discourse-cdn.com/v4/letter/d/e19adc/32.png) [@david55](https://community.asterisk.org/u/david55)\
**Post date:** [November 23, 2013, 10:44am UTC](https://community.asterisk.org/t/init-script/44503/8 "2013-11-23T10:44:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![david55](https://avatars.discourse-cdn.com/v4/letter/d/e19adc/32.png) [@david55](https://community.asterisk.org/u/david55)\
**Post date:** [November 23, 2013, 10:54am UTC](https://community.asterisk.org/t/init-script/44503/9 "2013-11-23T10:54:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![moferreira](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@moferreira](https://community.asterisk.org/u/moferreira)\
**Post date:** [November 23, 2013, 5:58pm UTC](https://community.asterisk.org/t/init-script/44503/10 "2013-11-23T17:58:09Z")

</div>

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

# Fix the problem with the library

ldconfig

# 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

# Finished

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.

---

<div class="post-metadata">

**Author:** ![miken32](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/miken32/32/7386_2.png) [@miken32](https://community.asterisk.org/u/miken32)\
**Post date:** [April 10, 2014, 4:11am UTC](https://community.asterisk.org/t/init-script/44503/11 "2014-04-10T04:11:34Z")

</div>

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:

```auto

```

Remove the redirection to get some error messages:

```auto

```

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:

```auto

```

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.)

---

<div class="post-metadata">

**Author:** ![larrymcp](https://avatars.discourse-cdn.com/v4/letter/l/7c8e57/32.png) [@larrymcp](https://community.asterisk.org/u/larrymcp)\
**Post date:** [January 4, 2016, 8:09am UTC](https://community.asterisk.org/t/init-script/44503/12 "2016-01-04T08:09:28Z")

</div>

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:

```auto

```
