Freeside:2.1:Documentation:Installation:FreeBSD

From Freeside
Jump to: navigation, search

Intro

FreeBSD 8.1 install of Freeside 2.1.1 + RT using ports (ports tree date 1/3/2011) where possible.

Please note this quick guide is written for someone already familiar with installing and maintaining a FreeBSD system. This is NOT a bare metal install guide. This guide leaves many apache modules that you may not need activated - feel free to pare things down once you have a working install.

My test system for this was a jail (specifically an ezjail jail on zfs), so if you're wondering "Can I run PostgreSQL and Freeside in a jail?", the answer is "Yes!".

NOTE - this is new, and it's based on quick notes I took while doing an install - please give me feedback on this or edit to clarify anything I've oversimplified or skipped

Install a ton of ports

I use portmaster for most ports tasks. It's in ports-mgmt/portmaster.

Here's the list, as output by "portmaster --list-origins". If you save this list to a file, something like "portmaster `cat /tmp/fs-port-list` should install all of these which should also pull in their own dependencies (I have a full list, but do not have upload perms on the wiki to put it here):

devel/libtool
lang/python26
archivers/unzip
devel/automake
devel/gmake
misc/help2man
www/p5-Apache-DBI-mp2
www/p5-Apache-Session
security/p5-Authen-Passphrase
finance/p5-Business-CreditCard
textproc/p5-CSS-Squish
devel/p5-Calendar-Simple
graphics/p5-Color-Scheme
databases/p5-DBD-Pg
databases/p5-DBIx-SearchBuilder
deskutils/p5-Data-ICal
devel/p5-DateTime-Format-Natural
devel/p5-DateTime-Format-Strptime
devel/p5-DateTime-Set
security/p5-Digest-HMAC
mail/p5-Email-Sender
misc/p5-File-CounterFile
devel/p5-File-ShareDir
net/p5-Frontier-RPC
graphics/p5-GD-Graph
textproc/p5-HTML-Format
textproc/p5-HTML-RewriteAttributes
www/p5-HTML-Scrubber
www/p5-HTML-Widgets-SelectLayers
www/p5-HTTP-Server-Simple-Mason
devel/p5-Hash-AsObject
security/p5-IO-Socket-SSL
devel/p5-IPC-Run
devel/p5-IPC-Run-SafeHandles
converters/p5-JSON
textproc/p5-Lingua-EN-Inflect
textproc/p5-Lingua-EN-NameParse
misc/p5-Locale-Codes
devel/p5-Locale-Maketext-Fuzzy
devel/p5-Locale-Maketext-Lexicon
misc/p5-Locale-SubCountry
devel/p5-Log-Dispatch
mail/p5-MIME-Tools
mail/p5-MIME-Types
devel/p5-Module-Versions-Report
dns/p5-Net-Domain-TLD
net/p5-Net-Ping
net/p5-Net-Ping-External
mail/p5-Net-SMTP-SSL
net/p5-Net-SSH
net/p5-Net-Server
net/p5-Net-Whois-Raw
net-mgmt/p5-NetAddr-IP
textproc/p5-Number-Format
devel/p5-POE
textproc/p5-Regexp-Common
textproc/p5-Spreadsheet-WriteExcel
devel/p5-String-Approx
textproc/p5-String-ShellQuote
devel/p5-Term-ReadKey
devel/p5-Test-Deep
devel/p5-Test-Exception
devel/p5-Test-Inline
devel/p5-Test-LongString
devel/p5-Test-Manifest
devel/p5-Test-Script
devel/p5-Test-Warn
textproc/p5-Text-CSV_XS
textproc/p5-Text-Quoted
textproc/p5-Text-Template
textproc/p5-Text-WikiFormat
textproc/p5-Text-Wrapper
devel/p5-Tie-IxHash
devel/p5-Time-Duration
devel/p5-Time-modules
devel/p5-Tree-Simple
devel/p5-UNIVERSAL-require
textproc/p5-XML-RSS
databases/postgresql90-server

Portmaster will query you for all options for these ports at the beginning of the build process. I did not deviate from the defaults much, but for completeness, here's all the options files:

TODO (This is a huge list, I have it in a file, but no perms to upload it to the wiki)

Install perl modules outside of ports

I downloaded the following from the CPAN site since they were not included in the ports system:

Unpack each, then cd to the directory you unpacked the source to and run "perl Makefile.pl". Look for any errors - if any dependencies are unsatisfied, that should be noted at the end of the output. Once all dependencies are satisfied, run "make" and "make install". Note that this simple install method will register these modules with the port system using bsdpan black magic (if you understand bsdpan, or have a good link to same, PLEASE ADD IT):

ls /var/db/pkg/bsdbpan-*
bsdpan-Business-US-USPS-WebTools-1.11
bsdpan-Chart-2.4.2
bsdpan-Email-Sender-Transport-SMTP-TLS-0.09
bsdpan-FS-%%%VERSION%%%  (one of these kids is doing his own thing, one of these kids is not like the others...)
bsdpan-HTML-Defang-1.04
bsdpan-Net-SMTP-TLS-ButMaintained-0.13

Basic Postgres Config

  • Enable in rc.conf, set some basic options, add apache while you're in there too (but don't start it yet)
# PORTS
apache22_enable="YES"
postgresql_enable="YES"
postgresql_data="/var/db/pgsql/data"
postgresql_initdb_flags="--encoding=latin1 --lc-collate=C"
  • Set some sysctl kernel values in /etc/sysctl.conf - I am not a Postgres expert, this should be high enough to get you going. There are many fine docs on the PostgreSQL website to get you setup properly.
# postgresql
kern.ipc.shmall=262144        # default 8192
kern.ipc.semmap=128             # default 30
  • Set those same values on the running system
# sysctl kern.ipc.shmall=262144
# sysctl kern.ipc.semmap=128
  • If you are running Freeside in a jail, this is needed in the host's rc.conf for postgres to start.
jail_sysvipc_allow="YES"
  • Create postgres' database directory, chown it to the pgsql user
#mkdir /var/db/pgsql
#chown pgsql /var/db/pgsql

Init the database and start it

#/usr/local/etc/rc.d/postgresql initdb
#/usr/local/etc/rc.d/postgresql start

If postgres does not start, ensure that you ran the above sysctl commands, and if you're in a jail, ensure you ran the sysctl command allowing jails to use shared memory.

Install Freeside

Fetch the Freeside tarball and unpack it:

cd /usr/local/src
fetch http://www.freeside.biz/freeside/freeside-2.1.1.tar.gz
tar xvzf freeside-2.1.1.tar.gz

The rest of this section is mostly copied directly from the normal Freeside 2.1 Installation Guide with equivalent FreeBSD commands where necessary. I have omitted the MySQL stuff for brevity and for your own well-being.

System User

Add the user and group `freeside' to your system:

pw useradd freeside -u 2000 -c 'Freeside User' -s /bin/sh -m

Database User

  • Create the freeside postgres user and give full access to the freeside database.
[ as postgres/pgsql user - "su pgsql" ]
$ createuser -P freeside 
Enter password for new role: supersecret
Enter it again: supersecret
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) y
Shall the new role be allowed to create more new roles? (y/n) n
^D

Database Access

  • Edit the top-level Freeside Makefile (ie: /usr/local/src/freeside-2.1.1/)
    • Configure the DATASOURCE to your DBI data source
    • Set the DB_TYPE (Pg or mysql)
    • See the DBI manpage and the manpage for your DBD for the exact syntax of your DBI data source.
    • Set DB_PASSWORD to the freeside database user's password.
DB_TYPE = Pg
DB_USER = freeside
DB_PASSWORD= supersecret
DATASOURCE = DBI:${DB_TYPE}:dbname=freeside

Database

  • Add the freeside database to Postgres:
[ As freeside user - "su freeside" ]
$ createdb -E LATIN1 freeside

Freeside Perl Modules

  • Build and install the Perl modules:
# cd /usr/local/src/freeside-2.1.1
# gmake perl-modules
# gmake install-perl-modules

I ran into no issues here - note that I'm using "gmake". BSD "make" may also work, but I'm more comfortable using gmake since that's what Ivan would be using.

Basic configuration Files

  • Ensure your Freeside Makefile has any configurable paths set to BSD-ish settings. The file is heavily commented, but I'm listing them here for completeness:
#changable now (some things which should go to the others still go to CONF)
FREESIDE_CONF = /usr/local/etc/freeside
FREESIDE_LOG = /usr/local/etc/freeside
FREESIDE_LOCK = /usr/local/etc/freeside
FREESIDE_CACHE = /usr/local/etc/freeside
FREESIDE_EXPORT = /usr/local/etc/freeside
#mod_perl v2 proper and prereleases 1.999_22 and after
APACHE_VERSION = 2
FREESIDE_DOCUMENT_ROOT = /usr/local/www/freeside
INIT_FILE = /usr/local/etc/rc.d/freeside
HTTPD_RESTART = /usr/local/etc/rc.d/apache22 stop || true; sleep 10; /usr/local/etc/rc.d/apache22 start
APACHE_CONF = /usr/local/etc/apache22/Includes
INSTALLGROUP = wheel
RT_ENABLED = 1
RT_DOMAIN = example.com
RT_TIMEZONE = US/Eastern
FREESIDE_URL = "http://bill.example.com/freeside/"
# not sure if it's safe to change this, so I didn't touch it
RT_PATH = /opt/rt3
  • Create the necessary configuration files and install them
# gmake create-config

NOTE: I had a failure here which involved the directories in /usr/local/etc/freeside not being created correctly due to "echo" being called with an odd option. I cannot find in my notes what I changed, but it was quite obvious. If you find any references to "echo -e", remove the "-e". I see the bash builtin has "-e", but /bin/echo does not.

Invoice Typesetting

  • If you are using typeset (ie: you want pdf invoices or PS printing) invoices, install fslongtable.sty:
# gmake install-texmf

Apache & Web GUI

This assumes you are running apache from ports with the stock port config files AND you are ONLY running FS here and won't have any other virt hosts. You probably don't want to be mixing other services on your billing host (or jail).

  • Configuration in httpd.conf
    • Remove any modules you don't want (I killed speling, userdir, dav stuff, any proxy-related things, and other stuff I know I don't need)
    • Enable mod_perl module in httpd.conf (LoadModule perl_module libexec/apache22/mod_perl.so in your Module section
    • Run as the freeside user (User freeside Group freeside)
    • Set your ServerAdmin and other basics as you'd like them
    • Set DocumentRoot and your main Directory directives to "/usr/local/www/freeside"
    • Ensure that the line that includes everything in /usr/local/etc/apache22/Includes is intact - this is where FS will dump it's apache configs
  • To install the web interface, run:
# gmake install-docs
  • Ensure you have a populated /usr/local/www/freeside directory
  • To install the apache configs, run:
# gmake install-apache
  • Ensure you have a populated /usr/local/etc/apache22/Includes directory (freeside-base2.conf, freeside-rt.conf)

Note: Do not attempt to restart Apache (httpd) yet.

Initialize Data

  • As the freeside user, run freeside-setup -d your.domain.name to create the database tables and initial data.
# su freeside
$ freeside-setup -d example.com

NOTE - If you have any failures here, it is very likely that you're missing a perl module. Look carefully at the command output for missing modules.

Additional System Users

  • Create the Freeside system users:
# su freeside
$ freeside-adduser -g 1 fs_queue
$ freeside-adduser -g 1 fs_daily
$ freeside-adduser -g 1 fs_selfservice

Create Freeside Users

  • Create one or more Freeside users (your internal sales/tech folks, not customer accounts):
# su freeside
$ freeside-adduser -g 1 username
$ htpasswd /usr/local/etc/freeside/htpasswd username
Password: 

Additional users can be added using the same command or from the web interface.

Queue Daemon

  • freeside-queued was installed with the Perl modules. Start it now and ensure that is run upon system startup. This is in the /usr/local/etc/rc.d/freeside script. The script is kind of a mess. For now, just comment out everything but the queued startup.

RT Installation/Config

I haven't changed this much. I had no issues with this step, but have not yet played around with RT. You may find more missing perl modules here...

  • Create a new Unix group called 'rt'
pw groupadd rt2 -g 2002
  • Configure RT (in /usr/local/src/freeside-2.1.1
# make configure-rt
  • If your database is not on the local machine you will need to edit /opt/rt3/etc/RT_SiteConfig.pm and set the DatabaseHost value
  • I believe this installs the files and drops the RT config in /usr/local/etc/apache22/Includes/
# make create-rt
  • Authentication errors?
    • Edit pg_hba.conf, change "ident sameuser" auth to "trust" for the line starting with "local all all"
    • Restart Pg
    • Revert the change back and restart Pg after this installation step
  • Install RT (configs? data? not sure)
make install-rt

Finalize

  • Restart Apache (httpd) and log into the web interface using the username and password you entered above.
  • Now proceed to the initial administration of your installation.