1

Server: Ubunto

Asterisk Version: 11.x

Directory: /usr/share/asterisk/agi-bin/ File: call_handle.php

Directory Permission: 755 root root File Permission: 755 root root

asterisk.conf

astagidir => /usr/share/asterisk/agi-bin

extensions.conf

same  => n,AGI(call_handle.php)

When I dial any number this AGI PHP Script is run. But, It will give me this message in asterisk console.

Asterisk Failed to execute '/usr/share/asterisk/agi-bin/call_handle.php': Permission denied

I am not sure why this message is comes up. It has execute permission with ROOT user

Ashwin Parmar
  • 3,025
  • 3
  • 26
  • 42

3 Answers3

3

The probable issue seems to be with the file ('/usr/share/asterisk/agi-bin/call_handle.php') not falling in the user group of Asterisk daemon that is asterisk:asterisk

That is to say - Asterisk daemon should have the ownership of this file.

Secondly, there is also a possibility that the user who is actually running this Asterisk daemon is not having the execute permission of this daemon.It should be there.

  • I have already checked with asterisk:asterisk user, group changed to that directory and files but not success. But, It may be need to check with user permission for asterisk – Ashwin Parmar Jan 17 '15 at 06:34
  • Yes, as i said the second possibility is of the user who is actually running this Asterisk daemon is not having the execute permission of this daemon.It should be there. Do check and update here – Rakesh Lamp Stack Jan 17 '15 at 06:37
  • I got the same error. the problem was that deamon asterisk was running with a diferent user (wasn't asterisk) and the ownership of the folders (/var/lib/asterisk/agi-bin/ and /var/lib/asterisk/) were for asterisk:asterisk the solutions was to change the ownership for the folders. – a52 Mar 30 '16 at 21:03
2

I got answer myself: Set PHP Envirement in my php script and it will run by asterisk.

I have set following in my php file at first line:

#!/usr/bin/env php

Reff: PHPAGI: Exec format error

Community
  • 1
  • 1
Ashwin Parmar
  • 3,025
  • 3
  • 26
  • 42
0

First ensure file can be executed

chmod a+x /usr/share/asterisk/agi-bin/call_handle.php

After that check that selinux not enabled or setup correctly

Disable selinux on Centos/Redhat

 echo "SELINUX=disabled" > /etc/sysconfig/selinux 

After that need reboot

arheops
  • 15,544
  • 1
  • 21
  • 27
  • FIle Permission: `-rwxrwxrwx 1 asterisk asterisk 1404 Jan 17 14:27 call_handle.php` I am using Ubuntu as OS – Ashwin Parmar Jan 17 '15 at 09:20
  • *"Disable selinux on Centos/Redhat"* - that's OK during development, but its not an acceptable solution in production. But turning it off like that in development makes it painful when the switch to production occurs. – jww Jan 17 '15 at 10:45
  • Selinux really usless thing when you deal with single asterisk service server. Just becuase you have allow to much to really protect server or disable to much for AGI process working. Also it require high admin skill in selinux, which for sure not topicstarter case. – arheops Jan 17 '15 at 12:34
  • Ubuntu's file is /etc/selinux/config – arheops Jan 17 '15 at 12:35