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 the EPEL and Zultron repos
The Zultron RPM repository is heavily dependent on EPEL.
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;
Make sure your web server is running as the user and group
/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
server.modules = (
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"
[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
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
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
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!