FreePBX RPM on lighttpd HOWTO
This post describes the new RPM for FreePBX in the Zultron repo. This RPM, compared to some others, is fully functional, and can be installed, removed and verified with the usual RPM commands, and contains other important pieces of infrastructure.
FreePBX RPM background
There are few other FreePBX RPMs. There is trac ticket at freepbx.org that refers to an outdated Trixbox RPM (that Trixbox itself doesn't use); this RPM basically drops the sources into /usr/src/freepbx, and runs install_amp in the %post script. After install, the installed files cannot be verified with rpm -V, and the administrator must still update the software from the web interface.
One reason there has never been an RPM is the install script, install_amp. It is a large, complex php script that takes care of everything from copying files around to creating links to customizing config files to setting up the database. For building an RPM, there is no option for the the script to install all the files and only the files in the %install section of the RPM, and then to allow the engineer to run the script in a database update only mode after the RPM is installed. The script also has no provision to perform module updates, and packaging the latest tarball from FreePBX.org will still require updates that must be downloaded separately.
This RPM solves some of these problems. It sets up most files and links that the install_amp script sets up, as well as files and links that are installed the first time you hit the red "Apply Configuration Changes" bar. All module updates are pre-installed from the web, both core framework modules and extra modules. The first time FreePBX runs, all modules will be up to date. The RPM also tries to uninstall cleanly without leaving anything unnecessary behind.
How to use
The Zultron FreePBX RPM requires a CentOS 5 install with Asterisk, mysql, a web server and php. I run CentOS 5.1 with lighttpd from EPEL and the Asterisk RPMs from the Zultron repo. Other Asterisk RPMs install files in /etc/asterisk and will conflict with the FreePBX RPM, so the Zultron Asterisk RPM may be a good choice.
This HOWTO only assumes you have a working CentOS 5 install, and will walk through the whole process from installing the Zultron repo and RPMs to configuring mysqld and lighttpd to running install_amp.
Install the EPEL and Zultron repos
The Zultron RPM repository is heavily dependent on EPEL.
Download the epel-release RPM from this link and the zultron-repo RPM from this link (URLs shortened for formatting's sake):
[root@bell tmp]# wget http://download.fedora.redhat.com/[...]/epel-release-5-3.noarch.rpm
[root@bell tmp]# wget http://distro.zultron.com/[...]/zultron-repo-1-1.el5.zult.noarch.rpm
[root@bell tmp]# rpm -i epel-release*.rpm zultron-repo*.rpm
Install the RPMs
Install the webserver, mysql, asterisk, php and freepbx RPMs, and cd to the lib directory:
[root@bell tmp]# yum install lighttpd lighttpd-fastcgi httpd-stub
[root@bell tmp]# yum install mysql-server
[root@bell tmp]# yum install dahdi-linux-kmdl-`uname -r` dahdi-linux dahdi-tools asterisk
[root@bell tmp]# yum install php freepbx
[root@bell tmp]# cd /usr/lib/freepbx
Create the databases and database users
Start the database, and create the users and databases:
[root@bell freepbx]# chkconfig mysqld on
[root@bell freepbx]# service mysqld restart
[root@bell freepbx]# mysqladmin create asterisk
[root@bell freepbx]# mysqladmin create asteriskcdrdb
[root@bell freepbx]# mysql asterisk < SQL/newinstall.sql
[root@bell freepbx]# mysql asteriskcdrdb < SQL/cdr_mysql_table.sql
[root@bell freepbx]# mysql # pick a good password here and remember for the install_amp step
mysql> GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost
-> IDENTIFIED BY 'SOMEPASSWORD';
mysql> GRANT ALL PRIVILEGES ON asterisk.* TO asteriskuser@localhost
-> IDENTIFIED BY 'SOMEPASSWORD';
mysql> flush privileges;
mysql> \q
Configure lighttpd
Make sure your web server is running as the user and group asterisk. Edit /etc/lighttpd/lighttpd.conf and set the user the webserver will run as:
server.username = "asterisk"
server.groupname = "asterisk"
Set the webroot:
server.document-root = "/usr/share/freepbx"
Enable and set up the mod_auth and mod_fastcgi modules:
server.modules = (
"mod_auth",
"mod_fastcgi" )
auth.backend = "htdigest"
auth.backend.htdigest.userfile = "/etc/lighttpd/htpasswd"
auth.require = ( "/" =>
(
"method" => "digest",
"realm" => "FreePBX",
"require" => "valid-user"
)
)
fastcgi.server = ( ".php" =>
( "localhost" =>
(
"socket" => "/var/run/lighttpd/php-fastcgi.socket",
"bin-path" => "/usr/bin/php-cgi"
)
)
)
Create the /etc/lighttpd/htpasswd file:
[root@bell freepbx]# lightdigest -u alice -p mypass -r FreePBX
You'll also have to change some permissions in the filesystem for the user asterisk so the webserver can write to them:
[root@bell freepbx]# chgrp asterisk /var/lib/php/session/
[root@bell freepbx]# chown -R asterisk:asterisk /var/log/lighttpd /var/run/lighttpd
Increase the memory limit to 100m in /etc/php.ini:
memory_limit = 100M ; Maximum amount of memory a script may consume
Now restart lighttpd:
[root@bell freepbx]# chkconfig lighttpd on
[root@bell freepbx]# service lighttpd restart
Run install_amp
Start Asterisk. Run the FreePBX installer script (in --no-files mode, since the RPM installs files for you), and make sure all /etc/asterisk files are owned by the asterisk user. Leave most of the answers default; you'll want to set the password for the DB (the same as you chose above), the Asterisk Manager interface (may or may not be the same), and the Flash Operator Panel (anything you remember is fine); and you'll need to type in the IP address or hostname of your server that you'll use in the URL for FreePBX. Start the FOP server. Finally, install the freepbx-modules RPM. We install the modules after running install_amp because the script will enable all modules; by installing the modules after the script, you can pick which extra modules to enable and which not to enable.
[root@bell freepbx]# ./install_amp --no-files
[root@bell freepbx]# amportal chown
[root@bell freepbx]# chkconfig fop-server on
[root@bell freepbx]# service fop-server start
[root@bell freepbx]# yum install freepbx-modules
[root@bell freepbx]# service asterisk restart
Finish up
That should be about it. Go to the link that install_amp printed at the end of its run. You should probably only see one notification, "No email address for online update checks"; any other notifications are problems. Hit the red "Apply Configuration Changes" button, and enjoy!
[...] is a detailed tutorial. March 22nd, 2009 in repo, [...]
Sir,
when I run ./install_amp –no-files it attempts to do operations on /var/www/html, which does not exist. I have tried setting the –webroot option to no effect, and even though it lists –fopwebroot as a valid option, it says invalid option when I try to actually run it. might you know what is wrong and what I can do to fix it?
Thank you for all your hard work in managing asterisk related packages, its very helpful!
I should probably mention that I am running CentOS 5.2 and, obviously, running the version provided by your package (which necessitated forgoing installing the packages you have for dahdi and compiling them myself, which shouldnt have hurt anything related to freepbx as there is a nice layer of separation). The companion freepbx-modules package is not installed at this point. I am literally stuck on the first command of the last 6 listed in your guide. The installer shows failures but does not abort at any point and even says the install was successful, so I am not sure if the output I am seeing is to be expected as you don’t mention it. I supposed I will attempt to continue and I will report my results here.
Well, that was quick. I needed to edit the various webroot/op_panel directory settings in /etc/amportal.conf, as they werent correct. That file was left over from an old install and it was confusing things, so it’s my fault.
Again, thanks for your hard work, Zultron. Much appreciated.
jde,
Glad you got it all sorted. Looks like there’s a new recordings module available, which I should be able to get packaged up in the next couple of days, so keep an eye out.
Thanks for the comments, I like to hear about what kind of problems people are having.
THANKS a lot for this guide!
I have afterwards just downloaded mpg123 and sox so that the MoH runs correctly…
Thanks again for this guide!!!
Best regards,
Chris
Chris, glad it helped!
I confess, I haven’t bothered setting up MoH yet. When I get around to it, I’ll definitely add the info to the HOWTO, as well as the RPMs to the repo.
Thanks!
Hello,
Is it working with CentOS 5.3 ?
Thx
LebPekin, I haven’t tried CentOS 5.3 yet. Maybe that project can come this weekend. Let me know if you give it a try. Thanks!
jman,
Are you having trouble keeping up with the more recent asterisk releases? Haven’t seen an update from you in a while. If you are having schedule/time trouble I’d be glad to help you maintain your packages if you can give me a rundown of the changes you make to the ATrpms src/specs. My job as it is basically consists of asterisk maintenance 8 hours a day, so time shouldn’t be trouble for me as long as I keep on top of new releases.
Hi, jde,
It’s more that Asterisk isn’t my main thing, so I don’t actively track updates. Now that I know that people are actually using my repo, I should put the mechanisms in place to notify me about updates. I’ll freshen up my packages over the weekend. Thanks for the heads up!
If you decide to update the RPMs yourself, you shouldn’t need to refer to the ATrpms packages; the zultron SRPMs are all available and it should be fairly easy to plug in a new Asterisk tarball and update the specfile. I think I stated in the instructions that the primary difference in the zultron RPMs is the removal of the /etc/asterisk config files to prevent conflict with the FreePBX RPM.
I have just set up freepbx on an Alix system (AMD Geode with 256MB memory, 2GB compact flash disk and a 160GB external USB disk for swap and the /var partition - uses about 8 watts), using Centos 5.4 and the epel and zultron repositories. It all went very smoothly once I had managed to get a Centos distro onto the compact flash. The only issue I had was with that I got the error “No package dahdi-linux-kmdl-2.6.18-164.2.1.el5 available” as obviously I am using a later kernel thanthe zultron packages were built for. I’ll try to resolve that.
I will sort out my notes into a proper blog entry.
Andrew, thanks for the heads up; I didn’t even realize CentOS 5.4 was out. If you build new RPMs for it, send them my way and I’ll add them to the repo. Otherwise, I probably won’t get around to this for a little while; school is killing me right now.
I’m getting 400 BAD REQUEST immediately after logging in, never see the freepbx portal at all. Any idea what I have missed?
Hi Patrick, hard to say. Any extra clues in the logs?
Also, these RPMs are getting a bit stale, which could be causing your problems. I’ll find some time soon to update everything.
yeah i am getting:
2010-05-14 16:49:02: (log.c.97) server started
2010-05-14 16:49:06: (http_auth.c.972) digest: unsupported backend (only htdigest or plain)
actually, thats gone away by specifying auth.backend =”htdigest” - now just never auths
Please completely disregard me, i hadnt copied all your instructions.
Hi Patrick, is your install working now? Congrats!
Hey My install is working great thanks, I just had an ignorant day where i didnt follow your instructions. Centos 5.4 all good, only I dont have a /usr/lib/asterisk/modules folder to place codecs… any idea?
ok, I think i’ll just stop posting here… sorry for the verbal diarrhoea - its 64 bit hence in /usr/lib64/modules/asterisk
Hi, thank you! I just installed successly. But , I havn’t see sip commands under asterisk cli.
Your work is really clear. Thank you very much for sharing it with us. Unfortunately I got lost with the passwords. When I aim to xx.xx.xx.xx to get into the FreePBX interface, the system propmts saying “A username and password are being requested by http://deleted. The site says: “FreePBX”". I cannot figure out what to input. Your help will be highly welcome. Congrats again! Enrique
Hi Enrique, I think the ’system prompt’ is a username/pasword dialog box in your web browser when browsing to htp://xx.xx.xx.xx?
In the ‘Configure lighttpd’ section of the article, there’s a command ‘[root@bell freepbx]# lightdigest -u alice -p mypass -r FreePBX’. You should replace ‘alice’ and ‘mypass’ with your username and password. If you pasted the command in directly, you can log in with those credentials. Try it to test, but change the password!
Good luck, and please write back with your results.
Dear jman, your suggestions worked 100%. Thank you very much.