The best of a bad lot
« The Dehumidifier Always Tweets Twice: Recent dehumidifier newsKeep track of configuration changes using etckeeper »

Revisited: Asterisk and FreePBX under Ubuntu 9.10 and Lighttpd on a Linode VPS

Permalink 12/06/09 18:42, by Ryan, Categories: Geekery, Howto , Tags: , , , , , , , , , , , , , , , , ,
This document has been superseded by an official article in the Linode Library, written by the most excellent and brave Amanda Folson, for Ubuntu 9.10 and Apache. If you're deploying Asterisk and FreePBX on a dedicated Linode, I highly recommend following that procedure. However, if you're a crazy person and want to use lighttpd on a multi-purpose system, feel free to give my procedure a try.
Looking to use Ubuntu 10.04 LTS? Take a look at VOIP with Linode, Ubuntu, Asterisk and FreePBX by Jake B.

I originally wrote this howto for Ubuntu 9.04 (Jaunty) a few months before Ubuntu 9.10 (Karmic) was released. I happen to have a spare system lying around right now, so I figure I might as well update this for 9.10!

Summary of major changes since the 9.04 document

  • Kernel package: It appears linux-image-server no longer installs a Xen-aware kernel, so I now use linux-image-ec2.
  • Zaptel replaced with DAHDI: Digium replaced Zaptel with DAHDI for Asterisk 1.6, which now ships with Ubuntu. This requires a change in package names, in addition to the usual changes one would expect between 1.4 and 1.6.
  • More links to the Linode Library: Since I wrote the original post in August, Linode has really fleshed out their documentation. I've harmonized some of the "opening moves" with their getting-started documentation to reduce confusion.
  • Now using upstart for spawning the FastCGI handlers: I figured there was a less cheesy way to do that.

Some concerns

I'm occasionally seeing the boot process locking up for awhile with nasty-looking kernel bug errors:

Code:

[   66.572527] BUG: soft lockup - CPU#1 stuck for 61s! [invoke-rc.d:1215]
[  132.080097] BUG: soft lockup - CPU#1 stuck for 61s! [invoke-rc.d:1215]
[  197.578163] BUG: soft lockup - CPU#1 stuck for 61s! [invoke-rc.d:1215]
[  263.072534] BUG: soft lockup - CPU#1 stuck for 61s! [invoke-rc.d:1215]

It eventually seems to pull out of it, but you might not want to do this on your production box until you're sure everything is happy and keen. If anyone knows anything about these errors, let me know. That said, I've been on a conference bridge with myself for the past ten minutes and everything's fine.

Without further adieu, here's the howto!

Rationale

FreePBX is a popular PHP front end for the Asterisk PBX system. It morphs the complex yet very flexible Asterisk configuration into something easier to use (yet still very extensible). When I worked for a business-class VoIP provider back in the day, we used FreePBX (and its predecessor, AMP) for most of our customer-premise PBX servers.

I prefer configuring and managing my Asterisk system using FreePBX. However, I can't justify an entire server for Asterisk, so I need it to coexist with a number of other applications. What I can justify is a VPS with relatively little memory, so some tuning is required.

The usual installation instructions assume the use of CentOS, Apache and mod_php for the stack. There are a few downsides to this configuration.

...

Since mod_php runs the PHP interpreter "within" Apache, it is restricted to running PHP code with Apache's permissions. For the purposes of FreePBX, which needs to edit configuration files owned by the "asterisk" user, this means setting Apache to run as "asterisk." Not an ideal configuration from a security standpoint, especially when the server is not dedicated to Asterisk.

The PHP folks strongly recommend that Apache use the prefork MPM with mod_php due to threading concerns. This is not a big deal for a dedicated Asterisk/FreePBX server, but if you're sharing it with a web server that might have popularity and limited memory, this can be a problem under high load. For this reason, I use lighttpd and PHP via FastCGI to service dynamic PHP content. This allows the web server to run threaded while PHP does its own thing, running under more specific uids.

I've also found the availability of software for CentOS lacks a lot of the less-popular software I enjoy, so I've standardized on Ubuntu to avoid straying from the repositories. As of this writing, I'm using Ubuntu 8.04 LTS on servers and Ubuntu 9.10 on desktops, but for this example, I am using 9.10.

So, time to get FreePBX operating properly in an entirely foreign environment!

The setup

The base for this installation consists of:

  • Server: Linode 360 Xen-based virtual private server
  • Distribution: Ubuntu 9.10, 32-bit, normal Linode deployment

The steps

I'm starting from the beginning, as I am doing this in a testbed. You can skip some steps if you already have a working system, or if you don't need particular features. Additionally, you might want to browse http://library.linode.com/ for more general advice on deploying, securing, and configuring a general purpose Linode VPS.

Prepare the system

I used Linode's Distribution Wizard to deploy a barebones Ubuntu 9.10 image using the default options. First, I log in and do my normal Linux prep:

Code:

# vi /etc/apt/sources.list
  --> uncomment the "universe" lines to enable the universe repositories
# apt-get update
  [output deleted]
  Fetched 10.2MB in 2s (3,439kB/s)                            
  Reading package lists... Done
# apt-get upgrade
  Reading package lists... Done
  Building dependency tree... Done
  0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
# adduser myuser   # replace "myuser" with your username
  Adding user `myuser' ...
  [dialogue deleted]
# echo "myuser ALL=(ALL) ALL" >> /etc/sudoers

(log back in as myuser)

Code:

$ sudo vi /etc/ssh/sshd_config
  --> edit to set PermitRootLogin no
$ sudo /etc/init.d/ssh restart
$ mkdir -m 700 .ssh
$ cat > .ssh/authorized_keys  # optional, if you want to use keys to log in
  --> paste ssh public key here, followed by ctrl-D

(log back in and make sure it uses the key!)

You may also want to change your hostname and set your timezone; see Setting Up a LAMP Server on Ubuntu 9.10 (Karmic) from the Linode Library for more info:

Code:

$ sudo -i
# echo "foovax" > /etc/hostname   # to set a system hostname; replace "foovax" accordingly
# hostname -F /etc/hostname
# echo "12.34.56.78 foovax.example.com foovax" >> /etc/hosts   # replace 12.34.56.78 with your IP address, etc.
# dpkg-reconfigure tzdata
  --> follow the prompts

Asterisk can send voicemail notifications via e-mail. Most e-mail providers require that mail be sent from a hostname that exists, so take a moment to add an A record to your domain.

I highly recommend using etckeeper to provide version control for your /etc directory. You can find more information on how to use this in Keep track of configuration changes using etckeeper, a recent post in my blog.

Configure the system to use Ubuntu's stock kernel

To make Asterisk's MeetMe subsystem happy, one needs the dahdi_dummy kernel module to provide timing. This is somewhat, and can be done with the stock Linode kernels, but you can run your distribution's Xen-aware kernel via PV-GRUB and thus "do what needs doing" without compiling by hand.

Note that the Ubuntu 9.10 asterisk package depends on dahdi, so you'll need to satisfy that dependency and convince apt that everything is OK somehow.

apt-get install linux-image-ec2 grub will install everything you need to boot an Ubuntuish kernel:

Code:

$ sudo apt-get install linux-image-ec2 grub
  Reading package lists... Done
  Building dependency tree... Done
  The following extra packages will be installed:
  ...
  0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
  Need to get 36.5MB of archives.
  After this operation, 107MB of additional disk space will be used.
  Do you want to continue [Y/n]?
  [output deleted]
$ sudo mkdir /boot/grub   # make sure it's there
$ sudo update-grub
  Searching for GRUB installation directory ... found: /boot/grub
  Searching for default file ... Generating /boot/grub/default file and setting the default boot entry to 0
  Searching for GRUB installation directory ... found: /boot/grub
  Testing for an existing GRUB menu.lst file ...
 
  Could not find /boot/grub/menu.lst file. Would you like /boot/grub/menu.lst generated for you? (y/N) y
  Searching for splash image ... none found, skipping ...
  Found kernel: /boot/memtest86+.bin
  Found kernel: /boot/vmlinuz-2.6.31-302-ec2
  Found kernel: /boot/memtest86+.bin
  Updating /boot/grub/menu.lst ... done

You'll then want to edit /boot/grub/menu.lst to change the groot line to groot=(hd0) (keep it commented out!):

Code:

## default grub root device
## e.g. groot=(hd0,0)
# groot=f9fe83cc-e8f0-42f0-b467-44121a0388cd

Delete the third line and replace it with this one:

Code:

# groot=(hd0)

Also, find the indomU line and set it to disable Xen detection:

Code:

# indomU=false

When that's all set, run update-grub again.

Code:

$ sudo update-grub
  Searching for GRUB installation directory ... found: /boot/grub
  Searching for default file ... found: /boot/grub/default
  Testing for an existing GRUB menu.lst file ... found: /boot/grub/menu.lst
  Searching for splash image ... none found, skipping ...
  Found kernel: /boot/vmlinuz-2.6.31-302-ec2
  Found kernel: /boot/memtest86+.bin
  Replacing config file /var/run/grub/menu.lst with new version
  Updating /boot/grub/menu.lst ... done

Once that's done, log into the Linode Dashboard and edit your configuration profile; you'll want to change to the pv-grub-x86_32 kernel. Save the profile, cross your fingers, and reboot! You can watch what's happening by using lish to access the console. If it doesn't boot properly, don't panic! Simply switch back to the Latest 2.6 Paravirt kernel and reboot again, then try to figure out what went wrong.

Under Ubuntu 9.04 (Jaunty), linux-image-server was the right kernel to use for Xen guests. Under Ubuntu 9.10 (Karmic), it appears linux-image-ec2 is the kernel that works best for me. This may change in future updates or versions; if one way doesn't work, try another.

Installing Asterisk

For the record, it took about 17 tries to get through this section when developing these instructions. This might be a good time to mention that you can easily do this in a small image of 2 to 3GB, should you want to shut down and duplicate the image every once in awhile. It's like saving the game before going to fight The Boss.

Ubuntu 9.10 ships Asterisk 1.6, with a dependency on DAHDI, a kernel module. First, we'll install dahdi, and then we'll install Asterisk.

You can download and install Asterisk from source (especially if you don't want dahdi), but if you're a wimp like me, Ubuntu's packages work... with a little bit of kicking. First, install the build environment and module-assistant, then prepare the system to dahdi's satisfaction:

Code:

$ sudo apt-get install build-essential module-assistant
$ sudo module-assistant -t update
$ sudo module-assistant -t prepare
$ sudo apt-get install gawk  # see bug comment below
$ sudo apt-get install dahdi dahdi-dkms dahdi-linux

Note regarding gawk: The dahdi build process requires gawk, but it's not a dependency on the package. Please see Launchpad bug 493304 for more information.

Once that's set, move on to Asterisk:

Code:

$ sudo apt-get install asterisk asterisk-config asterisk-doc asterisk-mp3 asterisk-mysql asterisk-sounds-main asterisk-sounds-extra

Time for a Courtesy Reboot

Alrighty, you've installed Asterisk and DAHDI, it's probably time to do a reboot to make sure everything comes up right.

Code:

$ sudo reboot

Go grab a sandwich and come back in five minutes. It's time for a breather. When it comes back, make sure running /sbin/lsmod still shows dahdi_dummy and that Asterisk is still running. Is it? Good.

You can bet your bippy I'm saving a copy of the image right now.

Installing lighttpd, PHP, MySQL, and FreePBX

It's time to install our web server, lighttpd, as well as the necessary elements to execute PHP code. As mentioned above, we're using the FastCGI method to handle PHP requests. We'll also grab MySQL, and the necessary libraries to tie it all together. MySQL will want you to set a root password; remember what this is, for you will need it later.

Code:

$ sudo apt-get install lighttpd php5-cgi php-pear php-db php5-mysql mysql-server mysql-client

Also, before we get too far down the road, let's save a copy of /etc/asterisk/modules.conf. There's a bit of a difference in philosophy between Debian/Ubuntu and FreePBX as far as what should be in this file. You'll need to copy this back in later...

Code:

$ sudo cp /etc/asterisk/modules.conf /etc/asterisk/modules.conf.original

If all goes well, you should be able to connect to your server on port 80 using a web browser; you'll get a placeholder page for now. Let's go ahead and get FreePBX working. I'm going to adapt the installation instructions for CentOS here. Grab the URL of the latest version from FreePBX's web site; as of this writing, it's freepbx-2.5.2.tar.gz. Download that into /usr/src:

Code:

$ cd /usr/src
/usr/src$ sudo wget http://mirror.freepbx.org/freepbx-2.5.2.tar.gz
          --2009-12-06 20:12:15--  http://mirror.freepbx.org/freepbx-2.5.2.tar.gz
          Resolving mirror.freepbx.org...
          ...
          2009-12-06 20:12:19 (2.01 MB/s) - `freepbx-2.5.2.tar.gz' saved [6206849/6206849]
/usr/src$ sudo tar -zxf freepbx-2.5.2.tar.gz
/usr/src$ cd freepbx-2.5.2

The following database initialization commands will ask for your MySQL root password you entered when you installed MySQL above. This is to test your memory. ;-) You'll also need to set a password for communication between FreePBX and MySQL... enter this instead of "secret" in the GRANT commands below.

Code:

/usr/src/freepbx-2.5.2$ sudo mysqladmin -p create asterisk
Enter password:
/usr/src/freepbx-2.5.2$ sudo mysqladmin -p create asteriskcdrdb
Enter password:
/usr/src/freepbx-2.5.2$ sudo mysql -p asterisk < SQL/newinstall.sql
Enter password:
/usr/src/freepbx-2.5.2$ sudo mysql -p asteriskcdrdb < SQL/cdr_mysql_table.sql
Enter password:
/usr/src/freepbx-2.5.2$ sudo mysql -p
Enter password:
mysql> GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY 'secret';
Query OK, 0 rows affected (0.00 sec)
 
mysql> GRANT ALL PRIVILEGES ON asterisk.* TO asteriskuser@localhost IDENTIFIED BY 'secret';
Query OK, 0 rows affected (0.00 sec)
 
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
 
mysql> \q
Buhbye

Now, let's fire off the FreePBX installer. (Oh boy.)

Code:

/usr/src/freepbx-2.5.2$ sudo ./install_amp --username=asteriskuser --password=secret
  [...]
Enter your USERNAME to connect to the 'asterisk' database:
[asteriskuser] (press enter here)
Enter your PASSWORD to connect to the 'asterisk' database:
[secret] (press enter here)
Enter the hostname of the 'asterisk' database:
[localhost] (press enter here)
Enter a USERNAME to connect to the Asterisk Manager interface:
[admin] (press enter here)
Enter a PASSWORD to connect to the Asterisk Manager interface:
[amp111] (set something for this password!) <---
Enter the path to use for your AMP web root:
[/var/www/html] /var/www/freepbx <---
Created /var/www/freepbx
Enter the IP ADDRESS or hostname used to access the AMP web-admin:
[x.xx.xx.xx] (put your real hostname/IP here)
Enter a PASSWORD to perform call transfers with the Flash Operator Panel:
[passw0rd] (press enter here)
Use simple Extensions [extensions] admin or separate Devices and Users [deviceanduser]?
[extensions] (press enter here)
Enter directory in which to store AMP executable scripts:
[/var/lib/asterisk/bin] (press enter here)
Created /var/lib/asterisk/bin
Enter directory in which to store super-user scripts:
[/usr/local/sbin] (press enter here)
 
/etc/amportal.conf writtenAssuming new install, --install-moh
added to command line
OK
[... and away it goes!]
 
Please update your modules and reload Asterisk by visiting http://...
 
**********************************************
* Some Warning That Isn't Relevant Right Now *
**********************************************

Wow, that was fast and furious. Wow. Don't bother going to that URL just yet; we'll get there soon enough.

Let's make a couple tweaks to configuration files. First, edit /etc/amportal.conf. This holds the configuration for FreePBX itself, and we want to change "AUTHTYPE=none" to "AUTHTYPE=database" around line 72.

Second, edit /etc/php5/cgi/php.ini. Around line 270, increase memory_limit = 16M to memory_limit = 100M. Near line 462, change magic_quotes_gpc = On to magic_quotes_gpc = Off. These adjustments will make FreePBX happy.

Before I forget, let's install a mail transport agent. This will let Asterisk send voicemail notifications via e-mail, and will also let FreePBX remind you when it needs updated!

Code:

$ sudo apt-get install postfix
  [Choose "Internet Site" unless you know you need something else.]
  [Also go with the default for System Mail Name, which will probably be the hostname you set awhile ago.]

Making it all work

Right now, FreePBX is installed and in control of Asterisk, Asterisk is installed and should be working, and lighttpd is there. However, we do need to do some more work to get the lighttpd/PHP/FreePBX chain working.

Using the current version of lighttpd in its default configuration, it will spawn its own PHP handlers (see /etc/lighttpd/conf-available/10-fastcgi.conf to see what I mean). Unfortunately, it can only spawn children as www-data, its own username. This makes privilege separation difficult, and defeats one of the reasons we're going with FastCGI in the first place.

To fix this, we're going to start our own php-cgi handlers with asterisk's username, and tell lighttpd to use them when requests come in for FreePBX. We'll do this by adding an upstart configuration file, and then we'll create a configuration module for lighttpd.

Create a file, /etc/init/fcgi-freepbx.conf containing the following:

Code:

# spawns fcgi handler for asterisk/freepbx
 
start on stopped rc RUNLEVEL=[2345]
stop on runlevel [!2345]
 
pre-start exec sleep 5
 
respawn
exec /usr/bin/spawn-fcgi -u asterisk -g asterisk -n -a 127.0.0.1 -p 4001 -C 2 -f /usr/bin/php-cgi

This spawns php-cgi to listen on localhost:4001 with two children spawned. Additionally, and importantly, it is running as user and group "asterisk". This gives the FreePBX scripts the opportunity to modify the Asterisk configuration. The pre-start exec sleep 5 helps avoid a race condition I've run into with testing: basically, if the spawned handlers go away too quickly, upstart respawns before the socket is free, creating a trainwreck. Pausing for a few seconds before respawning is a cheap way to fix this.

Let's tell upstart to start this up:

Code:

$ sudo start fcgi-freepbx
  fcgi-freepbx start/running, process 3345

Now, lighttpd needs to be made aware of your fastcgi handler. I do this by creating a file called /etc/lighttpd/conf-available/10-freepbx.conf:

Code:

server.modules  += ( "mod_fastcgi", "mod_access" )
 
$HTTP["host"] == "your.http.hostname.here" {
    # deny access to scary places
    $HTTP["url"] =~ "^/freepbx/admin/modules/" {
        url.access-deny = ("")
    }
    else $HTTP["url"] =~ "^/freepbx/" {
        dir-listing.activate = "disable"
        alias.url += ( "/freepbx/" => "/var/www/freepbx/" )
        fastcgi.server = (
            ".php" =>
                ( "freepbx" => (
                        "host" => "127.0.0.1",
                        "port" => 4001
            )))
    }
}

Change line three (the $HTTP["host"] line) to match the hostname or IP address with which you'll be accessing FreePBX.

Now, a couple permissions tweaks...

Code:

$ cd /var/www/freepbx
/var/www/freepbx$ sudo find . -type d | sudo xargs chmod 755
/var/www/freepbx$ cd /usr/share/asterisk
/usr/share/asterisk$ sudo chgrp -R asterisk agi-bin
/usr/share/asterisk$ sudo chmod -R 770 agi-bin

Then, enable the module and restart lighttpd!

Code:

$ sudo lighty-enable-mod freepbx
  Available modules: auth cgi fastcgi freepbx proxy rrdtool simple-vhost ssi ssl status urmom userdir
  Already enabled modules:
  Enabling freepbx: ok
  Run /etc/init.d/lighttpd force-reload to enable changes
$ sudo /etc/init.d/lighttpd force-reload
  Syntax OK
   * Stopping web server lighttpd [ OK ]
  Syntax OK
   * Starting web server lighttpd [ OK ]

You should then be able to go to http://yourhostname/freepbx/ and access the FreePBX server by clicking on FreePBX Administration and entering the admin username and password. Hooray! Click on the big "Apply Configuration Changes" banner and life should be good.

Remember how you copied /etc/asterisk/modules.conf a little while ago? Let's go ahead and put that back in.

Code:

$ sudo cp /etc/asterisk/modules.conf /etc/asterisk/modules.conf.freepbx
$ sudo cp /etc/asterisk/modules.conf.original /etc/asterisk/modules.conf

This would be a great time to reboot and make sure everything comes back up!

Code:

$ sudo reboot
 
Broadcast message from rtucker@warewolves
  (/dev/pts/0) at 13:37 ...
 
The system is going down for reboot NOW!

You can now add extensions, trunks, et cetera as you normally would with FreePBX! Head over to the Getting Started documentation on FreePBX's site and have fun! If anything didn't work right, or if you have questions, feel free to comment below and I'll take a look.

Did this work for you?

If so, please let me know in the comments section below! Your input and feedback are appreciated, and it's good to know if this actually helped someone out. Thanks for reading this!

This page is part of the
Ubuntu and Asterisk on Linode Web Ring!
PREVIOUS PAGE :: NEXT PAGE

31 comments

Comment from: john [Visitor]
*****
johnThanks a lot.
You are great!
12/07/09 @ 17:58
Comment from: Paul [Visitor]
Paulit does not boot.
i went to linode console and it says it cannot find device too boot.
i followed your instructions.
menu.lst had uuid... and root=uuid=....


from the menu i edited (e) to root=/dev/xvda and still gave me error that it cannot find device!!

i didnt know what to do and i went back to linode latest paravirt
12/07/09 @ 18:50
Comment from: paul [Visitor]
paulmy mistake. i actually did not put the one #, but not at all in front of settings, so update-grub ignore them
12/07/09 @ 18:53
Comment from: Mark [Visitor]
Marki cannot missing console at lish.
i followed these
http://www.linode.com/wiki/index.php/PV-GRUB
and these
http://www.linode.com/forums/viewtopic.php?p=24712
and still no login at lish.
last message is about star/stop ntpd

(i can ssh though)

any idea how to fix lish?
12/08/09 @ 00:19
Comment from: Mark [Visitor]
MarkActually it takes very long to have the login appear after reboot.
problem is at Running DKMS auto installation service for kernel 2.6.31-302-ec2 * dahdi (2.2.0.2)...
...done.
which takes a lot of time.

Why this should run at every reboot?!
12/08/09 @ 01:16
Comment from: Ryan [Member] Email
RyanJohn: Thanks! :-)

Paul: It's weird... I believe it uses that section as a "template" to create the actual configuration, so it needs to have those options commented out with exactly one hash. My first instinct is to uncomment them.

Mark: If you type "dmesg", do you have a lot of stuff that looks like this?

Code:

[ 66.572527] BUG: soft lockup - CPU#1 stuck for 61s! [invoke-rc.d:1215]
[ 66.572537] Modules linked in: ipv6 dahdi_transcode dahdi_dummy dahdi crc_ccitt

see more...

If so, I suspect you might be running into the same problem I am. Everything seems fine once it gets booted and running, but ugh... I don't like it.

I'm seriously considering trying to find the easiest way to install Asterisk without needing DAHDI, or perhaps finding some way to do it (nicely) with the stock Linode kernel... things took a turn for the worse with 9.10 in some ways.
12/08/09 @ 02:27
Comment from: Mark [Visitor]
Mark1. no, i dont have such messages as u in dmesg.
finally my problem was ntp configuration problem.

2.
Running DKMS auto installation service for kernel
is this necessary in each reboot even without upgrading kernel? can i disable this?
12/08/09 @ 03:46
Comment from: Mark [Visitor]
Mark1. since you install lightppd along with apache, you must put lightppd to run at different port. i also use apache at same vps, so i puted lightppd at another port

2. https://domain.com/freepbx works and shows
Voicemail & Recordings (ARI)
Flash Operator Panel (FOP)
FreePBX Administration
but if i click one of them it shows 403-forbiden
12/08/09 @ 06:12
Comment from: mark [Visitor]
markthe 403-forbiden is fixed.

can you do this also with nginx?

i use nginx as front end to apache.
nginx serves static content and apache dynamic php.
i heard that lightppd has memory leaches.

can u adapt a tutorial for nginx+apache setup for a VPS that uses the above serves also for hosting sites?

we need this to avoid having a 3rd server (lightppd) at small linode
12/08/09 @ 06:16
Comment from: Ryan [Member] Email
Ryan@mark: If you already have an existing web server (e.g. Apache or nginx), just configure it to use fastcgi on 127.0.0.1:4001 and skip the lighttpd step... the PBX administrator (i.e. you) will be the only one using the web interface, so there's no particular need to optimize it. I just use lighttpd for this example because it's what I use.

I'm also not too familiar with the internal operations of DKMS... this is my first time dealing with it, and the more I look at it, the more it scares me. :-) http://linux.dell.com/projects.shtml has some more information on it.
12/09/09 @ 01:43
Comment from: adam [Visitor]
*****
adamWhy is it when I try to edit the etc/php5/cgi/php.ini and etc/amportal.conf is says I do not have permission? I tried to do it in the terminal and also in gedit. I am new to all of this so there may be something I am overlooking.
12/09/09 @ 23:20
Comment from: adam [Visitor]
adamNever mind, my mistake I entered sudo edit etc/php5/cgi/php.ini instead of sudo gedit. Now I am having another problem. When I do /usr/share/asterisk$ sudo chgrp -R asterisk agi-bin it says:
chgrp: cannot access `agi-bin': No such file or directory
It does the same with:
/usr/share/asterisk$ sudo chmod -R 770 agi-bin.

Could Someone please help me with this. Where are these files?
12/10/09 @ 01:17
Comment from: Ryan [Member] Email
RyanHmm, /usr/share/asterisk/agi-bin/ should have a considerable number of files in there, courtesy of FreePBX:

Code:

-rwxr-xr-- 1 asterisk asterisk  1872 2009-12-08 06:47 checksound.agi
-rwxr-xr-- 1 asterisk asterisk 29774 2009-12-08 06:47 dialparties.agi
-rwxr-xr-- 1 asterisk asterisk 13321 2009-12-08 06:47 directory
-rwxr-xr-- 1 asterisk asterisk  6908 2009-12-08 06:47 enumlookup.agi
-rwxr-xr-- 1 asterisk asterisk  7735 2009-12-08 06:47 fixlocalprefix
-rwxr-xr-- 1 asterisk asterisk  1263 2009-12-08 06:47 list-item-remove.php
-rwxrwx--- 1 root     asterisk 26638 2009-12-06 22:23 phpagi-asmanager.php
-rwxrwx--- 1 root     asterisk 65896 2009-12-06 22:23 phpagi.php
-rwxr-xr-- 1 asterisk asterisk  4001 2009-12-08 06:47 recordingcheck
-rwxr-xr-- 1 asterisk asterisk 13369 2009-12-08 06:47 user_login_out.agi


What all do you have in /usr/share/asterisk ? -rt
12/11/09 @ 22:49
Comment from: Tom [Visitor] Email
*****
TomHi Ryan,
Thanks for pointing me here yesterday on IRC, just to let you know the upstart didn't respawn the spawn-fcgi when it died.
However, I found out if you add:
expect fork
to your /etc/init/ file it works perfectly.
This is because spawn-fcgi forks into the background and upstart presumes it has crashed, then restarts it, and it has a default to stop trying to restart it (and it keep forking) after 10 attempts in 5 seconds.
Using the above "expect fork" it gets the PID and monitors the forked process.
12/12/09 @ 12:10
Comment from: Ryan [Member] Email
Ryan@Tom: The "-n" option to spawn-fcgi also accomplishes the same effect: it keeps spawn-fcgi from forking. (This allows it to work on older upstart versions, too... you mentioned the "daemon" option on IRC but I haven't had a chance to poke at it yet.)

I did, however, notice that the restarts tended to fail... I suspect spawn-fcgi is exiting before everything's done listening on the TCP port, wedging things up. I'm throwing this in there as a bit of cheap insurance:

pre-start exec sleep 5

I sure do like Upstart, though!
12/13/09 @ 15:10
Comment from: amachu [Visitor]
****-
amachuWhat to do if apache2 is used instead of lighttpd?

particularly the section under:

"Making it all work"
12/30/09 @ 10:08
Comment from: Ryan [Member] Email
Ryan@amachu: The FreePBX install guide suggests changing the Apache configuration so it runs as User and Group asterisk and ensuring AllowOverride All is set should do the job, as long as PHP is otherwise working fine.

In theory, you could use my instructions to set up FreePBX and PHP under FastCGI, then configure Apache to use that -- especially if you don't want to run Apache as the asterisk user! But that'd be something to ask the Apache documentation about...
12/31/09 @ 02:26
Comment from: luluga [Visitor]
*****
lulugaRayn, After finished all the steps your provide, the http://mydomain/freepbx only display test without any gui. It that right? if not, how could I fix it??

Thanks,

01/28/10 @ 15:17
Comment from: luluga [Visitor]
*****
lulugaRyan,

After reinstallation, I got the "frog" on the http://mydomain/freepbx.
However, when I tried to click on any link (admin) I got 403 forbidden.
any idea??

Thanks,
01/28/10 @ 19:15
Comment from: Ryan [Member] Email
RyanHmmm... what are your permissions for /var/www/html/freepbx/*? Here's what I have:

Code:

rtucker@framboise:/var/www/html/freepbx$ ls -la
total 36
drwxr-xr-x 6 asterisk root     4096 2009-05-02 21:37 .
drwxr-xr-x 3 asterisk root     4096 2009-05-02 21:37 ..
drwxrwxr-x 8 asterisk asterisk 4096 2009-05-02 21:37 admin
drwxrwxr-x 2 asterisk asterisk 4096 2009-05-02 21:37 _asterisk
-rw-rw-r-- 1 root     root      602 2009-05-02 21:37 index.html
-rw-rw-r-- 1 root     root     4542 2009-05-02 21:37 mainstyle.css
drwxrwxr-x 2 asterisk asterisk 4096 2009-05-21 11:17 panel
drwxrwxr-x 7 asterisk asterisk 4096 2009-05-02 21:37 recordings


(note that this is on my "production" box running Ubuntu 8.04; your ls -la should be similar, but they might not be exact)

Also, does anything show up in /var/log/lighttpd/error.log when you get the 403?
01/29/10 @ 20:15
Comment from: Jun [Visitor]
*****
JunGreat installation procedures for asterisk + freepbx, thanks...
02/14/10 @ 20:06
Comment from: Jun [Visitor]
*****
JunOne problem accessing the panel, it throws an error like this:

Warning: file(/etc/amportal.conf) [function.file]: failed to open stream: Permission denied in /var/www/freepbx/panel/index_amp.php on line 4

Warning: Invalid argument supplied for foreach() in /var/www/freepbx/panel/index_amp.php on line 5

any idea what's wrong?
02/14/10 @ 20:09
Comment from: Jun [Visitor]
Junaccess permission to /var/www/frepbx/* is asterisk asterisk here is the err log from lighttpd:

2010-02-15 06:26:50: (mod_fastcgi.c.2618) FastCGI-stderr: Mon, 15 Feb 2010 06:26:51 +0800 - Failed to login.
02/14/10 @ 22:42
Comment from: Ryan [Member] Email
RyanJun: The op panel requires some additional work that I have not yet figured out. I generally use the Busy Lamp Field (BLF) method of monitoring extension status, since it works on the phones themselves.
02/15/10 @ 20:03
Comment from: Dennis Dunbar [Visitor] Email
*****
Dennis DunbarI get the Frog page but cannot get any further.

I too am just getting 403. ( Initially I got 500 )

I believe it has to do with the syntax of line 3 in:
server.modules += ( "mod_fastcgi", "mod_access" )

Could you give a working example?

Thanks for this excellent step by step.
03/03/10 @ 12:43
Comment from: Dennis Dunbar [Visitor]
*****
Dennis DunbarIf it helps here are my permissions:

switch@switch-desktop:/var/www/freepbx$ ls -la
total 36
drwxr-xr-x 6 root root 4096 2010-03-03 06:03 .
drwxr-xr-x 3 root root 4096 2010-03-02 15:03 ..
drwxr-xr-x 8 asterisk asterisk 4096 2010-03-03 06:03 admin
drwxr-xr-x 2 asterisk asterisk 4096 2010-03-03 06:02 _asterisk
-rw-r--r-- 1 root root 602 2010-03-03 06:03 index.html
-rw-r--r-- 1 root root 4542 2010-03-03 06:02 mainstyle.css
drwxr-xr-x 2 asterisk asterisk 4096 2010-03-03 06:02 panel
drwxr-xr-x 7 asterisk asterisk 4096 2010-03-03 06:03 recordings
switch@switch-desktop:/var/www/freepbx$
03/03/10 @ 13:47
Comment from: Ryan [Member] Email
RyanHmmm... are you seeing anything in lighttpd's error.log about that? Also, what does ps auxwww | grep asterisk return?

Also, is it asking for a username/password when you try to go to the /freepbx/admin/ page? It should be. Hmm.
03/05/10 @ 15:11
Comment from: john [Visitor] Email
*****
johnI keep getting the 403 error when i try to access the admin, ari or fop
my asterisk is built from source is that a problem?
03/07/10 @ 06:45
Comment from: Ryan [Member] Email
RyanJohn: Asterisk from source is fine. Next time I write one of these tutorials, I'll probably end up compiling from source: I actually don't use the pv_grub/dahdi stuff on my "production" setup as I don't need conferencing, so doing that whole rigmarole is a pain.

Which version of FreePBX are you using? I wrote these instructions for 2.5.2, and 2.7 is the current version. I wonder if something changed within FreePBX. I just upgraded to 2.7, so we'll see what happens ;-)
03/11/10 @ 03:01
Comment from: Dennis Dunbar [Visitor]
*****
Dennis DunbarI never get beyond the 'Welcome" page. The three other choices return "403 Forbidden"

Here is what was returned. I am unfamiliar with these.

root@switch:~# ps auxwww | grep asterisk
asterisk 2267 0.0 0.4 27032 2528 ? Ss 10:31 0:00 /usr/bin/php-cgi
asterisk 2269 0.0 0.3 27032 1596 ? S 10:31 0:00 /usr/bin/php-cgi
asterisk 2270 0.0 0.3 27032 1596 ? S 10:31 0:00 /usr/bin/php-cgi
root 15253 0.0 0.1 3044 808 pts/0 S+ 11:15 0:00 grep asterisk

Thanks again.
04/05/10 @ 15:21
Comment from: Ryan [Member] Email
Ryan@Dennis: That part looks right at least. I'm just not sure what's going on. Weird. Well, 10.04 is almost out, so perhaps I'll run into this when I do the next big FreePBX+Lighttpd+Ubuntu challenge. :-)
04/12/10 @ 02:54

Comments are closed for this post.

Blog posts come from a can. They were put there by a man in a factory downtown.

Recent Twitterings

    Stalk me with RSS

    Search the Blog

     

    Support the Beer Fund

    Powered by Linode: Life's too short for crappy hosting

    [Powered by Linode]

    blog soft

    © 1962-2014 by Ryan Tucker (Public Key)

    Contact | Help | Blog template by Asevo | blog tool | dedicated servers | authors