apache virtual hosts, user accounts with public html, webalizer reports

December 21st, 2008

Set up httpd.conf with a virtual host for each url.
/etc/httpd/conf/httpd.conf

Listen 80
NameVirtualHost *:80

<VirtualHost *:80>
ServerSignature off
DirectoryIndex index.php index.html index.htm index.shtml index.pl
LogLevel debug
HostNameLookups off
</VirtualHost>

<VirtualHost *:80>
ServerName www.labellepageantwear.com
ServerAlias *labellepageantwear.com
DocumentRoot /home/labelle/public_html/
DirectoryIndex index.php index.html index.htm index.shtml index.pl
ErrorLog /var/log/httpd/labellepageantwear.com-error_log
CustomLog /var/log/httpd/labellepageantwear.com-access_log common
</VirtualHost>

<VirtualHost *:80>
ServerName www.missidahofalls.org
ServerAlias *missidahofalls.org
DocumentRoot /home/missif/public_html/
DirectoryIndex index.php index.html index.htm index.shtml index.pl
ErrorLog /var/log/httpd/missidahofalls.org-error_log
CustomLog /var/log/httpd/missidahofalls.org-access_log common
</VirtualHost>

<VirtualHost *:80>
ServerName www.missrexburg.org
ServerAlias *missrexburg.org
DocumentRoot /home/missrex/public_html/
DirectoryIndex index.php index.html index.htm index.shtml index.pl
ErrorLog /var/log/httpd/missrexburg.org-error_log
CustomLog /var/log/httpd/missrexburg.org-access_log common
</VirtualHost>

# allow each user to have a public html folder
<Directory “/home/*/public_html”>
Options Indexes Includes FollowSymLinks
Order Deny,Allow
AllowOverride authConfig
Allow from all
Order allow,deny
</Directory>

# prevent index of labelle catalog
<Directory “/home/labelle/public_html/catalog”>
Options -Indexes
</Directory>

Restart apache for the configuration to take effect.
service httpd restart


create each access and error log file:
touch /var/log/httpd/missif.org-error_log
touch /var/log/httpd/missif.org-access_log
touch /var/log/httpd/missrexburg.org-error_log
touch /var/log/httpd/missrexburg.org-access_log


Setup webalizer for each virtual host.
mkdir /etc/webalizer
mv /etc/webalizer.conf /etc/webalizer/.
copy webalizer.conf to a unique file for each virtual host
cp /etc/webalizer/webalizer.conf /etc/webalizer/labellepageantwear.com.conf
cp /etc/webalizer/webalizer.conf /etc/webalizer/missidahofalls.org.conf
cp /etc/webalizer/webalizer.conf /etc/webalizer/missrexburg.org.conf

edit /etc/webalizer/webalizer.conf
leave LogFile /var/log/httpd/access_log
change OutputDir /var/www/usage/default
I changed the hostname to the static IP on the local LAN HostName 192.168.1.50
Every thing else stayed the same.

Now, update the following items for each virtual host in their conf file
LogFile /var/log/httpd/missrexburg.org-access_log
OutputDir /var/www/usage/missrex
HistoryName /var/lib/webalizer/missrex.webalizer.hist
IncrementalName /var/lib/webalizer/missrex.webalizer.current
HostName www.missrexburg.org


Setup a folder for each webalizer report:
mkdir /var/www/usage/default
mkdir /var/www/usage/labelle
mkdir /var/www/usage/missif
mkdir /var/www/usage/missrex

in each folder place a copy of msfree.png and webalizer.png
cp /var/www/usage/msfree.png /var/www/usage/labelle/.
cp /var/www/usage/webalizer.png /var/www/usage/labelle/.

I also created a folder for all the old data
mkdir /var/www/usage/old_data
and moved all the old webalizer stuff into the old_data folder
mv /var/www/usage/* /var/www/usage/old_data/.


Setup the webalizer cron script to run each conf file:
/etc/cron.daily/00webalizer
#! /bin/bash
# update access statistics for the web site

#if [ -s /var/log/httpd/access_log ] ; then
# /usr/bin/webalizer
#fi

for i in /etc/webalizer/*.conf; do /usr/bin/webalizer -c $i; done

exit 0


I also set up /etc/httpd/conf.d/webalizer.conf to allow an index of the usage folder and only allow browsers on the LAN to see webalizer reports.

#
# This configuration file maps the webalizer log analysis
# results (generated daily) into the URL space. By default
# these results are only accessible from the local host.
#
Alias /usage /var/www/usage

<Location /usage>
Order deny,allow
Deny from all
Allow from 127.0.0.1
Allow from 192.168.1. # local subnet
Allow from ::1
Options +Indexes
</Location>

Restart apache for the configuration to take effect.
service httpd restart


Last of all, make sure each domain’s dns entry is pointing to your ip address. I found out the hard way that this doesn’t work if you are using forwarding….
Try ping or nslookup on one of your domains to make sure the ip address is correct.


Rush’s Kitchen Supply

December 16th, 2008

9 camera system at Rush’s Kitchen Supply in Idaho Falls, Idaho. I had to use several “lipstick” cameras since only part of the store has a ceiling where any thing could be mounted.

Cedric’s Family Restaurant

December 16th, 2008

Here are a few pictures of the system at Cedric’s.
There are 9 cameras connected to the Linux Server and a Video Quad Mux.
The Linux box records time-lapse video and streams to the internet. The Mux feeds a T.V. in the office.

Lookup Caller ID name from number via mysql

December 16th, 2008

My trixbox CE current release is 2.6.1.13, this assumes default passwords for mysql.


Setup mysql with the following 3 commands at the linux CLI.
# mysqladmin -uroot -ppassw0rd create cidlookup
# mysql -uroot -ppassw0rd -Dcidlookup -vv -e ‘CREATE TABLE `callerid` (`number` VARCHAR(10) NOT NULL ,`name` VARCHAR(50) NOT NULL,`notes` VARCHAR(200) NOT NULL, PRIMARY KEY (`number` , `name`))’
# mysql -uroot -ppassw0rd -Dcidlookup -vv -e “INSERT INTO callerid VALUES (”,’unknown’,'blank’)”

( The blank entry gives something to report if CID is blank, other wise the first tuple from the table is selected. )


Next, in the web page gui select: PBX > PBX settings
Then select the CallerID Lookup Sources and Add Lookup Source

Source Description: local mysql
Source Type: MySQL

Host: localhost
database: cidlookup
query: SELECT name FROM callerid WHERE number LIKE ‘%[NUMBER]%’
username: root
password: passw0rd


Now, in the web page gui select: PBX > PBX settings
Then select the inbound routes that are to look up the name in mysql.
Change CID Lookup source to local mysql (or whatever you named it).


Now we need an easy way to manage the mysql database table.
Put this CGI Perl script in /var/www/cgi-bin, I named mine cid.pl

Download: cid.pl

E-mail Voicemail volume too low

December 10th, 2008

“Use gain when recording the voicemail message (optional) : [ ]”
found in; “setup > general settings”, doesn’t work.

I finally found a setting that does work in
/etc/asterisk/voicemail.conf

[general]
;1st listed format gets emailed
; format = wav49|wav
format = wav|wav
volgain=12.0
attach = yes
pbxskip = yes ; Don’t put [PBX]: in the subject line

Daily Reports

November 1st, 2008

Each morning at about 4:00 am a small report of Key Performance Indicators (KPIs) is sent to my server. The information is checked and compiled into one report that I receive each morning via email. This should alert me of many common issues and give me time to fix them before they cause problems. 

The following information is sent in the daily report:

* Name of the system sending the report.

* The IP address the system is reporting from.
Some times Internet Service Providers change the Internet Address of the connection. My server actually collects this data when the report is received. It is not generated by the remote server. This information provides the current address for remote connectivity.

* Date and Time report is sent
This is compared to the time the report is received. Each remote server checks in with the NIST atomic clock via the internet each night. This information verifies the remote server’s clock is correct and adjusts properly for Day Light Savings. Very important for the surveillance video time stamp!

* Up time.
How long the server has been up and running. Corresponds to the last time the remote server was restarted.

* Load.
This is a percentage of how often the CPU is working during the past 15 minutes. If this is over 1.00 there are programs waiting on the CPU and the CPU can’t get every thing done it needs to.

* Disk Use:
How full the hard disk is.

* Free Memory
How much RAM is free.

* httpd running?
This is the web server, the program that communicates with your internet browser.

* motion running?
motion is the program that takes care of video cameras.

* inadyn running?
If you access the remote server with an address that ends with homelinux.net, this is the program that keeps .homelinux.net updated with the remote IP address.

* sshd running?
This is the program that allows remote access to the server’s operating system.

Below is an example of the summarized report I receive via e-mail each day.

The daily report is only a summary a few critical KPIs that give a quick snapshot of how the server is doing. This should allow to time to investigate and resolve issues before they become problems.

A complete report of the server’s Key Performance Indicators can be found in the menu system on the server: Setup -> Utilities -> Server Stats. I need to post an explanation of Server Stats soon.

Wake Up Call

October 30th, 2008

Add FreePBX module.

goto http://www.freepbx.org/trac/changeset/5065 and get the file wakeup-1.0.tgz
Load your gui up of freepbx
Click on the tools tab
select module admin
Select Upload Module and then browse for the file
Select the file and press upload
After it is uploaded, go to module admin again, under “provides a feature code” the wakeup module should be there.
Click on check for updates online at the top of the page.

Go back under “provides a feature code”, click on wakeup and select install.
Then click process at the bottom of the page.

apply your changes with a reload

in linux
mkdir /tmp/wakeup
chown asterisk /tmp/wakeup
chgrp asterisk /tmp/wakeup


another way…

After the initial install of TrixBox 2.6 there is a wake up script wakeup.php already in /var/lib/asterisk/agi-bin

So all I had to do was add the following in /etc/asterisk/extensions_custom.conf
exten => *62,1,Answer
exten => *62,n,AGI(wakeup.php)
exten => *62,n,Hangup

And restart with amportal restart.

This is quick and easy, but does not add the features in the FreePBX module.

my TrixBox CE release is 2.6.1.11

DD-WRT DNSMasq tftp to TrixBox

October 19th, 2008

In a DD-WRT router to have dhcp point to the TrixBox for tftp, set the following:
In the DD-WRT control panel select:
Administration > Services > scroll down to DNSMasq
DNSMasq = enable
Additional DNS Options:
dhcp-option=66,192.168.1.40

192.192.1.40 is my TrixBox.

Ring Back Solved

October 16th, 2008

I had trouble with TrixBox ringing after hanging up. After hanging up, a couple seconds latter all of the phones in the incoming ring group would ring, caller ID reporting “unknown”. Answering would result in listening to dial tone. It did not matter if I was terminating or originating.

I have a digium tdm410p wildcard with 2 FXO modules. Ring back was happening on both FXO ports.

I added options wctdm24xxp ringdebounce=1536 in /etc/modprobe.conf and restarted the system.

Looks like the voltage swing/change on disconnect was being interpreted as a ring cycle. Increasing the ring-de-bounce parameter took care of it.

My zaptel driver version is 1.4.11, asterisk 1.4.21.2-2 on trixbox v2.6.1.10

Since this is a driver setting I don’t think any of the many, many, changes I made in my zapata.config made a difference. However, it is posted below.

I’m not going to play with zapata.conf again until my wife is out of town, I think she has had enough…

;
; Zapata telephony interface
;
; Configuration file

[trunkgroups]

[channels]

language=en
context=from-zaptel
signalling=fxs_ks
rxwink=300              ; Atlas seems to use long (250ms) winks
;
; Whether or not to do distinctive ring detection on FXO lines
;
;usedistinctiveringdetection=yes

usecallerid=yes
hidecallerid=no
callwaiting=no
usecallingpres=no  ; pri channles only
callwaitingcallerid=no
threewaycalling=no
transfer=no ;needs to threeway calling to work
cancallforward=yes
callreturn=yes
echocancel=yes
echocancelwhenbridged=no
;echotraining=800
rxgain=3.0
txgain=-5.0
group=0
callgroup=1
pickupgroup=1
immediate=no

callprogress=yes
progzone=us

answeronpolarityswitch=no
hanguponpolarityswitch=yes
;busydetect=yes
ringtimeout=8000

;faxdetect=both
faxdetect=incoming
;faxdetect=outgoing
;faxdetect=no

;Include genzaptelconf configs
#include zapata-auto.conf

group=1

;Include AMP configs
#include zapata_additional.conf

Asterisk weather with wx200

October 11th, 2008

I hacked this together. I to get this to work I had to first install wx200 on my TrixBox.

I did this first with Festival TTS, but it did not work very good. Then I found out that Flite is already installed on TrixBox and it works much better. So, Festival has been removed and the code below has been changed to use Flite for Text To Speech.

This is the code in extensions_custom.conf.

exten => *61,1,Answer
exten => *61,n,Flite(Hello.)
exten => *61,n,Flite(The weather report is a follows.)
exten => *61,n,System(/usr/local/bin/wx200 192.168.1.50 --temp --humidity --local --gust --chill --trend -u > /tmp/wx-temp.txt)
exten => *61,n,ReadFile(TEMP=/tmp/wx-temp.txt,60)
exten => *61,n,Set(PRESSURE=${MATH(${TEMP:10:5}+4.85)}) ; add the offest
exten => *61,n,Set(PRESSURE=${PRESSURE:0:5})                         ; cleanup the extra zeros
exten => *61,n,Flite(The temperature is ${TEMP:0:5} degrees fahrenheit. The humidity is ${TEMP:7:2} percent. The wind is ${TEMP:18:5} miles per hour. The wind chill is ${TEMP:30:3} degrees fahrenheit. The barometeric pressure is ${PRESSURE:0:5} and  ${TEMP:35:10}.)
exten => *61,n,Wait(1)
exten => *61,n,System(rm -f /tmp/wx-temp.txt)
exten => *61,n,Flite(Thank you for calling\, goodbye.)
exten => *61,n,Wait(1)
exten => *61,n,Hangup()