Question

How to activate asterisk server and connect Zoiper to asterisk server? (FreePBX business app)

Hello, I need your help. As I was trying to make my own voip system using freepbx digitalocean business app, I had a problem. Here is what I’ve tried on it.

curl -v -u username:password http://server_ip:8088/ari/endpoints

Here is the result (logs):

*   Trying server_ip:8088...
* Connected to server_ip (server_ip) port 8088 (#0)
* Server auth using Basic with user 'username'
> GET /ari/endpoints HTTP/1.1
> Host: server_ip:8088
> Authorization: "token here"
> User-Agent: curl/7.81.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Server: Asterisk/18.6.0
< Date: Thu, 04 Jan 2024 13:48:33 GMT
< Cache-Control: no-cache, no-store
< Content-type: application/json
< Content-Length: 113
< 
[
  {
    "technology": "PJSIP",
    "resource": "anonymous",
    "state": "offline",
    "channel_ids": []
  }
* Connection #0 to host server_ip left intact
sudo systemctl start asterisk

Here is the error log:

Asterisk is already running.
Can't open PID file /var/run/asterisk/asterisk.pid (yet?) after start: No such file or directory
Failed to start LSB: Asterisk PBX.

Unit asterisk.service entered failed state.
asterisk.service failed.
pam_unix(sudo:session): session closed for user root

How can I fix those issues? Hope to hear from you soon. Thank you.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
January 8, 2024

Hello Seymen,

The issue you’re encountering with Asterisk on your FreePBX DigitalOcean business app seems to be related to the way Linux handles the /var/run directory after a reboot. This directory, including /var/run/asterisk, often gets cleared upon reboot on many Linux distributions.

To resolve the “Asterisk is already running but can’t find PID file” issue, here are some steps you can take:

  1. Create the Directory and Set Permissions:

    • You can manually create the /var/run/asterisk directory and set the correct ownership. You can add these commands in the /etc/init.d/asterisk script to automatically execute them when the system starts.
    • Use the following commands:
      if ! [ -d /var/run/asterisk ] ; then   
         mkdir /var/run/asterisk   
         chown $AST_USER:$AST_GROUP /var/run/asterisk   
      fi
      
    • Replace $AST_USER and $AST_GROUP with the appropriate user and group names for your Asterisk setup.
  2. Check and Fix Permissions:

    • Ensure that the user running Asterisk has the correct permissions for the /var/run/asterisk/ directory and the asterisk.ctl file within it.
    • The permissions issue might be preventing Asterisk from accessing or creating the required .ctl and .pid files.
  3. Verify Asterisk is Running:

    • Sometimes, the issue could be because Asterisk isn’t running at all. When Asterisk starts, it should create the asterisk.ctl file. If it’s not running or halts immediately due to an error, this file won’t be created.
    • Run Asterisk in console mode with increased verbosity to monitor for any errors during startup:
      asterisk -cvvvvv
      
    • This can help identify if there are underlying issues causing Asterisk to halt.
  4. Consider SELinux Configuration:

    • If SELinux is enabled on your system, ensure that it’s properly configured to allow Asterisk to create the necessary files.

Do try these steps and see if they resolve the issue!

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel