Failed to copy from module agi-bin


I followed the great howto here on

edit: don’t follow the above link. Those instructions don’t work. Instead use the excellent directions at and update them if you have any added insight.

and got up and running quickly. The problem is that when the freepbx installer asked me some of my file locations, I think I got one wrong, i.e., accepted the default incorrectly. Now I’m getting the error quoted in subject, with the details “copy(/usr/share/asterisk/agi-bin/user_login_out.agi): failed to open stream: Permission denied”.

I checked and that file doesn’t exist in that path on my system. It does however exist at /var/www/freepbx/admin/modules/core/agi-bin/user_login_out.agi. I guess I need to copy it to where it’s expected or edit a config file somewhere so freepbx knows where to find it?

I’m using freepbx 2.5.1 and I’ve updated my modules. System is Ubuntu 8.04 server x86_64 with all other packages from the standard ubuntu repos.


The issue is it has attempted to copy it to the location it stated in the error and can not due to a permissions issue.

Where you found the file is correct and where it copies it from.

So the owner:group permissions are incorrect for the file and/or folder /usr/share/asterisk/agi-bin/user_login_out.agi

Please run the command: amportal chown
This will reset the permissions to what it expect them to be.

Thanks for the pointer. Unfortunately ‘amportal chown’ didn’t fix the problem for me. These are the file permissions for the files in question:

# ls -l /var/www/freepbx/admin/modules/core/agi-bin/ total 88 -rwxrwxr-x 1 asterisk asterisk 1872 2008-07-01 21:45 checksound.agi -rwxrwxr-x 1 asterisk asterisk 28930 2008-09-15 23:06 dialparties.agi -rwxrwxr-x 1 asterisk asterisk 13321 2008-07-01 21:45 directory -rwxrwxr-x 1 asterisk asterisk 3780 2008-07-26 08:40 enumlookup.agi -rwxrwxr-x 1 asterisk asterisk 7735 2008-07-26 08:40 fixlocalprefix -rwxrwxr-x 1 asterisk asterisk 1263 2008-07-01 21:45 list-item-remove.php -rwxrwxr-x 1 asterisk asterisk 4001 2008-08-31 16:57 recordingcheck -rwxrwxr-x 1 asterisk asterisk 13369 2008-10-20 13:28 user_login_out.agi

# ls -l /usr/share/asterisk/ total 340 drwxr-xr-x 2 asterisk asterisk 16 2009-02-09 14:52 agi-bin drwxr-xr-x 3 asterisk asterisk 16 2009-02-09 20:06 firmware drwxr-xr-x 2 asterisk asterisk 48 2009-02-09 20:06 keys drwxr-xr-x 2 asterisk asterisk 1 2008-09-29 19:20 moh drwxr-xr-x 12 asterisk asterisk 53248 2009-02-09 20:06 sounds drwxr-xr-x 2 asterisk asterisk 1 2008-09-29 19:21 static-http

When ‘amportal chown’ didn’t work I made some changes. I believe some of the directories in /usr/share/asterisk were owned by root:root and I changed that. I also did a recursive ‘chmod a+rx’ in this directory, but still no joy.

Do I have all the permissions right? Seems like they’re pretty permissive at this point. Maybe I have a setting wrong elsewhere?

edit: also tried

as per compused’s suggestion. Still getting the error.

I changed apache2 to run as asterisk and the error is gone, things appear to be functioning as hoped.

I’m still puzzled why it didn’t work before, as apache was running www-data and www-data was a member of group asterisk. {shrug}

Ihe installation directions for asterisk say that apache needs to be owned by asterisk, it helps to follow them.

When you step outside the box things don’t always work the way you expect.

I don’t understand why it seems that almost all Ubuntu users think they know better then the 10’s of thousands of installs of asterisk that they can change things and it will just work.

Yes it is a design issue with asterisk and the proper place to address it is with them over at In the mean time following the directions on building a system using asterisk should always follow the directions of asterisk even if somebody else say’s otherwise until this issue is addressed.

Yes it is possible to make it work otherwise but FreePBX and it’s forums are not the place for that support. We assume that the directions are being followed to the letter otherwise it’s a great big witch hunt.

The installation directions for asterisk on Ubuntu are actually pretty simple and consist of exactly one line in a terminal: apt-get install asterisk.

I agree with your point that it’s risky to step outside the box, but a person would be wise to consider that the apt package manager is very good and very popular; to a user of debian-based systems, changing the ownership of apache is very much stepping outside the box and something we are loathe to do with good reason.

I don’t understand why a few people at think they know better than the hundreds of thousands of linux users who years ago discovered package managers and the peace of mind they bring to managing systems that have to do more than just one thing.

Normally I just ignore flamebait like the post I’m responding to, but I happen to think better of the FreePBX project. I’ve done a lot of digging through these forums in the past week and it seems pretty apparent that there is this open source cliche ‘holier than thou’, ‘rtfm’, ‘google it up’ attitude theme throughout that the more mature projects have managed to transcend by now.

FreePBX is a good product with the potential to be great, and making the forums a friendlier place will be key to starting that transition.

It’s not the FreePBX developers or support people who put the asterisk user restriction on the installation, asterisk has that as a base restriction due to how they wrote the code.

We all go through changing the user for apache no matter which distro you use, it just seems that this one particular group is more unwilling to do it then any other. CentOS has it’s package manager and we have to reconfigure for it also. But you don’t find users not doing that step that’s all I was trying to say.

Please feel free to take the directions you followed and update them with corrections and they can be added to the site so that others do not have this issue going forward.

My searches have turned up very little on installing freepbx or asterisk on Ubuntu, and what is out there seems to be inconsistent. I guess this underlines your suggestion that I should update the documentation where it exists.

After some more searching I found the instructions in the wiki ( and although at first glance they appear to be a copy of the instructions I followed at, they are in fact a little more accurate and up to date.

Had I followed the wiki in the first place I could have perhaps avoided the trouble.

I’ll try and get the installation doc’s section to include a pointer to that set (or move it over to the documentation section). Thanks for pointing out that they are a better set.