Build A HylaFax Server With AvantFax Frontend Using Debian Etch

Install Debian. I used the basic barebones install option. I did some things that were done because of preference, and not necessary. I have marked them approriately. I encourage contributions from anyone who would like to add or correct something in this HowTo to contact me so I can fix it. I have installed this setup twice following these instructions and used Avantfax 2.3.0. Thanks to all the resources who helped me figure this out. Especially Razametal, who submitted a fantastic Spanish language walkthrough on ecualug.org.

**********optional section***************

Remove cdrom source:

 # nano /etc/apt/sources.list

Throw a # in front of the cdrom source.

Bring your box up to date:

# apt-get update
# apt-get upgrade

Reboot:

 # shutdown –r now

***********end of optional section************

Log in as root.

Give the machine a static IP:

 # nano /etc/network/interfaces

Replace the “inet dhcp” with something similar to this:

iface eth0 inet static
    address 192.168.1.51
    netmask 255.255.255.0
    network 192.168.1.0
    broadcast 192.168.1.255
    gateway 192.168.1.1

Reset the connection:

 # ifdown eth0 && ifup eth0

***********optional***********

Install ssh server:

    # apt-get install openssh-server

Log in as root via PuTTY (or continue on the terminal).

***********end of optional section*********

At this point, you need to know what port your modem is at. It should be at one of the /dev/ttyS*'s. If you don't know this, start googleing.

Install hylafax:

# apt-get install hylafax-server
# faxsetup

Allow it to run faxmodem to connect the modem. Use defaults except for:

# Area code [415]? <your area code>
# Phone number of fax modem [+1.999.555.1212]? <your phone number>
# Local identification string (for TSI/CIG) ["NothingSetup"]? <a name for your fax server>
# Protection mode for received facsimile [0600]? 0644
# Protection mode for session logs [0600]? 0644
# Protection mode for ttyS0 [0600]? 0666

Use class 1 modem unless you know better.

Allow users from your subnet access to the fax service:

 # nano /etc/hylafax/hosts.hfaxd

Add to the end of the file:

192\.168\.:::

Reboot:

 # shutdown -r now

Test the server:

 # faxstat -a -s

You should get something like this:

    # HylaFAX scheduler on <your server name>: Running
    # Modem ttyS2 (<your phone number>): Running and idle

Add a fax user. This will create a user named "user" with userID 101 and no password.

 # faxadduser -u 100 user

Add an administrator. This will create a user named admin with admin password <password>:

 # faxadduser -a <password> -p <password> -u 100 admin

At this point, hylafax works. You can test it by connecting  a client like WHFC to try it out. If you need to switch up the config later, use these files:

/etc/hylafax/config
/etc/hylafax/config.ttyS*

Now, lets get messy and install a cute web front end on it. 

Install the prerequisites:

# apt-get install apache2-mpm-prefork apache2-utils apache2.2-common \
libapache2-mod-php5 libapr1 libaprutil1 libpq4 libsqlite3-0 php5-cli php5-common \
mysql-server imagemagick libtiff4-dev netpbm libnetpbm10-dev libungif-bin \
libungif4-dev sudo postfix php-mail php-mail-mime php-file php-db php5-mysql \
 psutils wdiff

# cd /usr/src
# wget http://easynews.dl.sourceforge.net/sourceforge/avantfax/avantfax-2.3.0.tgz
# tar zvxf avantfax-2.3.0.tgz
# cd avantfax-2.3.0

You can edit avantfax/includes/config.php if you need to, but I didn't have to change anything.

Move avant to web folder and set permissions:

# mv /usr/src/avantfax-2.3.0/avantfax /var/www/
# chmod -R 777 /var/www/avantfax/tmp /var/www/avantfax/faxes

Rename original faxrcvd and notify scripts. Replace with avantfax ones:

# cd /var/spool/hylafax/bin
# mv faxrcvd faxrcvd.old
# mv notify notify.old
# ln -s /var/www/avantfax/includes/faxrcvd.php /var/spool/hylafax/bin/faxrcvd
# ln -s /var/www/avantfax/includes/notify.php /var/spool/hylafax/bin/notify
# mv /usr/bin/faxcover /usr/bin/faxcover.old
# ln -s /var/www/avantfax/includes/faxcover.php /usr/bin/faxcover

Edit create_tables.sql to use avantfax database:

 # nano create_tables.sql

Add "USE avantfax;" to top.

Edit setup.sh to chown to "root.root":

 # nano setup.sh

Change apache.apache to "root.root".

Run the setup script:

# ./setup.sh

Add two scripts to root's crontab:

 # crontab -e
# runs once an hour to update the phone book
0 * * * * /var/www/avantfax/includes/phb.php
# runs once a day to remove old files
0 0 * * * /var/www/avantfax/includes/remold.php

Switch up your Apache settings:

 # nano /etc/apache2/sites-enabled/000-default

Change it to this:

NameVirtualHost *
 <VirtualHost *>
         ServerAdmin webmaster@localhost
       
         DocumentRoot /var/www/avantfax
         <Directory />
                 Options FollowSymLinks
                 AllowOverride None
         </Directory>
         <Directory /var/www/avantfax>
                 Options Indexes FollowSymLinks MultiViews
                 AllowOverride None
                 Order allow,deny
                 allow from all
                 # This directive allows us to have apache2's default start page
                 # in /apache2-default/, but still have / go to the right place
                 #RedirectMatch ^/$ /apache2-default/
         </Directory>
       
         ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
         <Directory "/usr/lib/cgi-bin">
                 AllowOverride None
                 Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
                 Order allow,deny
                 Allow from all
         </Directory>
       
         # Possible values include: debug, info, notice, warn, error, crit,
         # alert, emerg.
         LogLevel warn
       
         CustomLog /var/log/apache2/access.log combined
         ServerSignature On
     Alias /phpmyadmin "/usr/share/phpmyadmin/"
     <Directory "/usr/share/phpmyadmin/">
         Options Indexes MultiViews FollowSymLinks
     </Directory>
     Alias /doc/ "/usr/share/doc/"
     <Directory "/usr/share/doc/">
         Options Indexes MultiViews FollowSymLinks
         AllowOverride None
         Order deny,allow
         Deny from all
         Allow from 127.0.0.0/255.0.0.0 ::1/128
     </Directory>
       
 </VirtualHost>

Restart Apache:

# /etc/init.d/apache2 restart

Go to http://<yourIP>/admin. Log in using u/n: afadmin, p/w: password.

Configure your modems. For /dev/ttyS2, use ttyS2. Mind the caps... as always.

Add a user.

Reboot:

 # shutdown -r now 

Try to start hylafax:

 # /etc/init.d/hylafax start

You will get some errors about one file being newer than the other. mv the newer file over the older one. Repeat 3 times.

Once you can start it successfully, reboot:

 # shutdown -r now

Now you users can access the fax server login at http://<faxhostname>.

Share this page:

9 Comment(s)