[How To] Install and configure MySAR on freeBSD 9

[How To] Install and configure MySAR on freeBSD 9



When I try install MySAR (MySQL Squid Access Report 2.1.4) on my FreeBSD 9 server I have got many problems. Now I want to write installation process and solutions of those problems in this article.

Installing MySAR

Get mysar port

whereis mysar
mysar: /usr/ports/www/mysar

Install mysar

cd /usr/ports/www/mysar
make
install
clean

Configure apache

Create Apache virtual host

vim /usr/local/etc/apache22/Includes/virtual-hosts.conf

Paste into

<Directory "/usr/local/mysar/www/">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

<VirtualHost 192.168.0.1:80">
DocumentRoot /usr/local/mysar/www/
ServerAdmin root@domain.com
ServerName mysar.domain.com
ServerAlias www.maysar.domain.com
CustomLog /var/log/mysar.domain.com-access_log combined
ErrorLog /var/log/mysar.domain.com-error_log
</VirtualHost>

192.168.0.1 is Your server IP address

/usr/local/etc/rc.d/apache22 restart

Install and Configure MySAR MySQL database

Create and edit config.ini file

Open mysar.domain.com and install MySAR MySQL database

cp /usr/local/mysar/etc/config.ini.example /usr/local/mysar/etc/config.ini

Open and edit Crontab

vi /etc/crontab
# mysar not only runs every minute but it also expects to be run every minute.
# If you wish to change this, you need to adjust not only the cron entries below but also the $maxRunTime inside bin/mysar-importer.php
* * * * *       root    /usr/local/mysar/bin/mysar-resolver.php > /usr/local/mysar/log/mysar-resolver.log 2>&1
0 0 * * *       root    /usr/local/mysar/bin/mysar-maintenance.php > /usr/local/mysar/log/mysar-maintenance.log 2>&1

# IMPORTER
## PHP - Slow but tested. The defult choice, for now.
* * * * *       root    /usr/local/mysar/bin/mysar-importer.php > /usr/local/mysar/log/mysar-importer.log 2>&1

## Binary. Fast but untested. Needs compile. Check README.
#* * * * *      root    /usr/local/bin/mysar > /usr/local/mysar/log/mysar-importer.log 2>&1
If You are using stansard MySAR scripts, be informed, that here is a wrong paths in /usr/local/mysar/etc/* files. If needed change /usr/local/mysarbin/mysarbin to /usr/local/mysarbin/mysar/bin and /usr/local/mysarwww to /usr/local/mysar/www
Also in my computer I have changed first lines of php files located in /usr/local/mysar/bin to #!/usr/local/bin/php

Optional: Disable administrator menu

vi /usr/local/mysar/www/index.php

change

$template='administration'

to

$template='administration.old'

Leave a Reply

Your email address will not be published. Required fields are marked *