找回密码
 注册

QQ登录

只需一步,快速开始

查看: 657|回复: 3

Installing FreePBX(4)

[复制链接]
发表于 2010-12-1 16:03:02 | 显示全部楼层 |阅读模式
Setting up the database

FreePBX utilizes a MySQL database to store all of the configurations shown in the web interface it provides.

Under Ubuntu Server 8.10, MySQL must simply be started. A MySQL root password is entered during the Ubuntu install process, and Ubuntu automatically sets up the MySQL service to start at boot time. To start MySQL, type the following command:

/etc/init.d/invoke-rc.d mysql start

A separate user account under which Asterisk can run should also be created. It is common for Asterisk to run as the root user on a system (and almost always an easier way to make things work), but it is a security risk. Should Asterisk or Apache be compromised by a remote exploit, the flaw cannot be used to take over the entire server when Asterisk runs as its own user. Create a user account called asterisk that Asterisk will run as, using the following command:

adduser -gecos "Asterisk PBX" --home /var/lib/asterisk --system --group asterisk

Note that all of the above is a single adduser command, and should be typed as if it was written on a single line.

Create a database to store Asterisk configuration and another to store call detail records:

mysqladmin -u root -p create asterisk
mysqladmin -u root -p create asteriskcdrdb
Enter your MySQL root password when prompted.

FreePBX has created prepared SQL statements to set up the structure of each database it uses. Type the following to switch to the /usr/src directory and download the FreePBX installer archive:

cd /usr/src

sudo wget http://internap.dl.sourceforge.net/sourceforge/amportal/freepbx-2.5.1.tar.gz

The above command will download FreePBX version 2.5.1. To check for the current version of FreePBX, visit the site http://freepbx.org/download-freepbx. The current version will be listed next to the Download FreePBX button. If the listed version is newer than 2.5.1, it should be used instead. Extract FreePBX using the following command:

tar zxf freepbx-2.5.1.tar.gz
Switch to the FreePBX <code>SQL</code> directory:
cd freepbx-2.5.1/SQL

The two prepared statements provided by FreePBX are newinstall.sql and cdr_mysql_table.sql. The newinstall.sql file contains the necessary SQL statements to create the tables that store all FreePBX configuration data (extensions, call targets, call routing information, etc.). The cd_mysql_table.sql file contains one single statement that creates a CDR table for storing all call details records. To run the SQL statements contained in these files, run the following commands:

mysql -u root -p asterisk < newinstall.sql
mysql -u root -p asteriskcdrdb < cdr_mysql_table.sql
Enter your MySQL root password when prompted.

Now we must grant the Asterisk user permissions on the Asterisk and Asterisk CDR databases. FreePBX will not function without this access. To grant permissions, we must first drop to a MySQL shell:

mysql -u root -p

Enter your MySQL root password when prompted.

Once at the MySQL shell, type the following commands to grant the appropriate privileges to the Asterisk user. Remember to replace freepbxdbpassword with a password of your choice and note that the password should be enclosed in single quotes.

mysql> GRANT ALL PRIVILEGES ON asterisk.* TO asterisk@localhost IDENTIFIED BY 'freepbxdbpassword';
mysql> GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asterisk@localhost IDENTIFIED BY 'freepbxdbpassword';
mysql> flush privileges;
mysql> \q

Setting up file permissions

The final installation step is to set up appropriate permissions and general configurations. To make the required configuration changes, the examples shown as follows make use of the sed command. The sed command can take a stream of input and rewrite it on the fly based on patterns listed in the command. The syntax for the following sed commands used works as follows:

sed -i "s/pattern_to_find/replacement_pattern/" /path/to/file

The -i option tells sed to edit the input file in place, such that the listed file is changed and a new file with the requested changes is not created in its place.

The s/ tells sed that we are looking to replace a specific pattern with text of our own.

The pattern_to_find token should be replaced by the text that we are searching for. This can be a normal alphanumeric pattern, or a regular expression.

The replacement_pattern token should be replaced with the value that we want to replace the pattern_to_find token with.

As FreePBX will need to interact with Asterisk, the Apache web server must be set up to run as the asterisk user. To change the user and the group that Apache runs as, enter the following commands as the root user:

sed -i "s/www-data/asterisk/" /etc/apache2/envvars

We must also allow FreePBX to override various default Apache directives. To allow the directive overrides, type the following into the console:

sed -i "s/AllowOverride None/AllowOverride All/" /etc/apache2/apache2.conf

The Asterisk run directory (where the Asterisk PID file will be stored) should be changed to /var/run/asterisk:

sed -i "s/astrundir => \/var\/run/astrundir =>
\/var\/run\/asterisk/" /etc/asterisk/asterisk.conf

PHP will need to be configured to allow for large file uploads up to 20 MB, as FreePBX modules can reach above the default 8 MB limit. To change the PHP limits type the following:

sed -i "s/post_max_size = 8M/post_max_size = 20M/" /etc/php5/apache2/php.ini
sed -i "s/upload_max_filesize = 2M/upload_max_filesize = 20M/" /etc/php5/apache2/php.ini

The Asterisk run directory (where the process ID file is stored) is located on a temporary file system under Ubuntu. Each time the server reboots, the directory will disappear along with its associated permissions. To correct this, the directory must be created and permissions set at boot time:

echo "mkdir /var/run/asterisk" >> /etc/rc.local
echo "chown -R asterisk:asterisk /var/run/asterisk" >> /etc/rc.local

Note that the chown statement as above is one command and should be typed on a single line.

Finally, the asterisk user should be set up as the owner of several directories that Asterisk will use during normal operation:

chown -R asterisk:asterisk /var/spool/asterisk/
chown -R asterisk:asterisk /var/log/asterisk/

At this point, all packages should be installed and configured correctly. It is recommended that your server be rebooted now to allow all changes to take effect.

发表于 2011-5-31 13:12:36 | 显示全部楼层
好的帖子现在越来越难遇到了,偶尔遇到一个就必须顶





MillashaMillashaMillashaMillasha
发表于 2011-6-1 23:05:31 | 显示全部楼层
发表于 2011-6-7 22:41:07 | 显示全部楼层
楼主好帖 不回不行啊 哈!

为了好帖我沉闷一天的手终于控制不了要去回帖了,好了,我回了....



三仙矛草,三仙矛草,三仙矛草,三仙矛草
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|BC Morning Website ( Best Deal Inc. 001 )

GMT-8, 2026-4-10 05:19 , Processed in 0.014847 second(s), 15 queries .

Supported by Weloment Group X3.5

© 2008-2026 Best Deal Online

快速回复 返回顶部 返回列表