Bandwidthd+Postgresql数据库配置笔记
本系列文章由ex_net(张建波)编写,转载请注明出处。
http://blog.csdn.net/zjianbo/article/details/16717625
作者:张建波 邮箱: 281451020@qq.com 电话:13577062679 欢迎来电交流!
一、安装前的准备工作
(1)安装前请参考http://blog.csdn.net/zjianbo/article/details/16623879,了解Postgresql数据库的安装配置。
(2)创建 bandwidthd-pgsql 账号,该账户用来让Bandwidthd登录Postgresql数据库的
root@ubuntu:~# su - postgres
postgres@ubuntu:~$ psql
psql (9.1.9)
Type "help" for help.
postgres=# CREATE USER bandwidthdpgsql;
CREATE ROLE
postgres=# ALTER USER bandwidthdpgsql PASSWORD '123456';
ALTER ROLE
postgres=# \q
postgres@ubuntu:~$ exit
logout
root@ubuntu:~#
(3)创建数据库
create database bandwidthdpgsql;
和第(2)步一样,还是用 su - postgres登录后执行
说明:
在Ubuntu下,不需要用 schema.postgresql 这个脚本创建表了。这一点和用源码安装方式有点不一样,可能是Ubuntu实在是考虑的比较周全把。
二、安装Bandwidthd软件包
apt-get install bandwidthd-pgsql
三、稍微修改Bandwidthd配置文件即可
vi /etc/bandwidthd/bandwidthd.conf
/etc/init.d/bandwidthd restart #重启bandwidthd服务
启动后2~3分钟,用pgadmin工具看看数据库,就可以可能到数据了。
四、配置php页面
vi /etc/bandwidthd/debian-db.php
例如:
$dbuser='bandwidthdpgsql';
$dbpass='123456';
$basepath='';
$dbname='bandwidthdpgsql';
$dbserver='localhost';
$dbport='5432';
$dbtype='pgsql';
vi /etc/apache2/conf.d/bandwidthd
Alias /bandwidthd /var/lib/bandwidthd/htdocs
<Directory /var/lib/bandwidthd/htdocs>
DirectoryIndex index.php
AllowOverride None
order deny,allow
deny from all
#allow from 127.0.0.0/255.0.0.0 ::1/128
allow from all
<IfModule mod_php5.c>
php_flag magic_quotes_gpc Off
php_flag track_vars On
php_value include_path .
</IfModule>
<IfModule !mod_php5.c>
<IfModule mod_actions.c>
<IfModule mod_cgi.c>
AddType application/x-httpd-php .php
Action application/x-httpd-php /cgi-bin/php
</IfModule>
<IfModule mod_cgid.c>
AddType application/x-httpd-php .php
Action application/x-httpd-php /cgi-bin/php
</IfModule>
</IfModule>
</IfModule>
</Directory>
敲入上面的配置信息,当然,你可以用 phppgadmin的配置文件作为范本,cp一个出来修改哈即可。
这2步完成后,重启apache即可
/etc/init.d/apache2 restart
打开浏览器,选择你的传感器后,你就可以看到流量信息了。。。。
例如:http://192.168.1.4/bandwidthd/sensors.php
五、如果有不清楚的地方,用 man bandwidthd 看看
FILES
/usr/sbin/bandwidthd - daemon binary.
/etc/init.d/bandwidthd - startscript.
/etc/bandwidthd/bandwidthd.conf - configuration file.
/var/run/bandwidthd.pid - main process id file.
/var/lib/bandwidthd/ - log directory.
/var/lib/bandwidtd/htdocs/ - html and graphs output directory.
六、如果还有不明白的地方,推荐你看看下面的资料
(1) Ubuntu 12.04环境下配置Postgresql和phppgadmin http://blog.csdn.net/zjianbo/article/details/16623879
(2)Bandwidthd完整实战笔记_1 http://blog.csdn.net/zjianbo/article/details/15026111