Difference between revisions of "Freeside:2.1:Documentation:Installation:FreeBSD"

From Freeside
Jump to: navigation, search
(New page: ==Summary== 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 ...)
 
(Summary)
 
(15 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Summary==
+
==Intro==
  
 
FreeBSD 8.1 install of Freeside 2.1.1 + RT using ports (ports tree date 1/3/2011) where possible.   
 
FreeBSD 8.1 install of Freeside 2.1.1 + RT using ports (ports tree date 1/3/2011) where possible.   
Line 5: Line 5:
 
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.
 
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.
  
==1. Install a ton of ports==
+
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.
 
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:
+
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):
  
 
<pre>
 
<pre>
Line 94: Line 98:
  
 
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:
 
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:
 +
 +
* [http://search.cpan.org/dist/Business-US-USPS-WebTools Business::US::USPS::WebTools 1.11]
 +
* [http://search.cpan.org/dist/Chart Chart 2.4.2]
 +
* [http://search.cpan.org/dist/Email-Sender-Transport-SMTP-TLS Email::Sender::Transport::SMTP::TLS 0.09]
 +
* [http://search.cpan.org/dist/HTML-Defang HTML::Defang 1.04]
 +
* [http://search.cpan.org/~fayland/Net-SMTP-TLS-ButMaintained-0.13 Net-SMTP-TLS-ButMaintained 0.13]
 +
 +
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):
 +
 +
<pre>
 +
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
 +
</pre>
 +
 +
==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)
 +
<pre>
 +
# PORTS
 +
apache22_enable="YES"
 +
postgresql_enable="YES"
 +
postgresql_data="/var/db/pgsql/data"
 +
postgresql_initdb_flags="--encoding=latin1 --lc-collate=C"
 +
</pre>
 +
*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 [http://www.postgresql.org/ PostgreSQL website] to get you setup properly.
 +
<pre>
 +
# postgresql
 +
kern.ipc.shmall=262144        # default 8192
 +
kern.ipc.semmap=128            # default 30
 +
</pre>
 +
*Set those same values on the running system
 
<pre>
 
<pre>
# This file is auto-generated by 'make config'.
+
# sysctl kern.ipc.shmall=262144
# No user-servicable parts inside!
+
# sysctl kern.ipc.semmap=128
# Options for apache-2.2.17_1
+
</pre>
_OPTIONS_READ=apache-2.2.17_1
+
*If you are running Freeside in a jail, this is needed in the host's rc.conf for postgres to start.
WITHOUT_THREADS=true
+
<pre>
WITHOUT_MYSQL=true
+
jail_sysvipc_allow="YES"
WITHOUT_PGSQL=true
+
</pre>
WITHOUT_SQLITE=true
+
*Create postgres' database directory, chown it to the pgsql user
WITHOUT_IPV6=true
+
<pre>
WITHOUT_BDB=true
+
#mkdir /var/db/pgsql
WITH_AUTH_BASIC=true
+
#chown pgsql /var/db/pgsql
WITH_AUTH_DIGEST=true
+
</pre>
WITH_AUTHN_FILE=true
+
Init the database and start it
WITHOUT_AUTHN_DBD=true
+
<pre>
WITH_AUTHN_DBM=true
+
#/usr/local/etc/rc.d/postgresql initdb
WITH_AUTHN_ANON=true
+
#/usr/local/etc/rc.d/postgresql start
WITH_AUTHN_DEFAULT=true
 
WITH_AUTHN_ALIAS=true
 
WITH_AUTHZ_HOST=true
 
WITH_AUTHZ_GROUPFILE=true
 
WITH_AUTHZ_USER=true
 
WITH_AUTHZ_DBM=true
 
WITH_AUTHZ_OWNER=true
 
WITH_AUTHZ_DEFAULT=true
 
WITH_CACHE=true
 
WITH_DISK_CACHE=true
 
WITH_FILE_CACHE=true
 
WITHOUT_MEM_CACHE=true
 
WITH_DAV=true
 
WITH_DAV_FS=true
 
WITHOUT_BUCKETEER=true
 
WITHOUT_CASE_FILTER=true
 
WITHOUT_CASE_FILTER_IN=true
 
WITHOUT_EXT_FILTER=true
 
WITHOUT_LOG_FORENSIC=true
 
WITHOUT_OPTIONAL_HOOK_EXPORT=true
 
WITHOUT_OPTIONAL_HOOK_IMPORT=true
 
WITHOUT_OPTIONAL_FN_IMPORT=true
 
WITHOUT_OPTIONAL_FN_EXPORT=true
 
WITHOUT_LDAP=true
 
WITHOUT_AUTHNZ_LDAP=true
 
WITH_ACTIONS=true
 
WITH_ALIAS=true
 
WITH_ASIS=true
 
WITH_AUTOINDEX=true
 
WITH_CERN_META=true
 
WITH_CGI=true
 
WITH_CHARSET_LITE=true
 
WITHOUT_DBD=true
 
WITH_DEFLATE=true
 
WITH_DIR=true
 
WITH_DUMPIO=true
 
WITH_ENV=true
 
WITH_EXPIRES=true
 
WITH_HEADERS=true
 
WITH_IMAGEMAP=true
 
WITH_INCLUDE=true
 
WITH_INFO=true
 
WITH_LOG_CONFIG=true
 
WITH_LOGIO=true
 
WITH_MIME=true
 
WITH_MIME_MAGIC=true
 
WITH_NEGOTIATION=true
 
WITH_REWRITE=true
 
WITH_SETENVIF=true
 
WITH_SPELING=true
 
WITH_STATUS=true
 
WITH_UNIQUE_ID=true
 
WITH_USERDIR=true
 
WITH_USERTRACK=true
 
WITH_VHOST_ALIAS=true
 
WITH_FILTER=true
 
WITH_VERSION=true
 
WITHOUT_PROXY=true
 
WITHOUT_PROXY_CONNECT=true
 
WITH_PATCH_PROXY_CONNECT=true
 
WITHOUT_PROXY_FTP=true
 
WITHOUT_PROXY_HTTP=true
 
WITHOUT_PROXY_AJP=true
 
WITHOUT_PROXY_BALANCER=true
 
WITHOUT_PROXY_SCGI=true
 
WITH_SSL=true
 
WITHOUT_SUEXEC=true
 
WITHOUT_SUEXEC_RSRCLIMIT=true
 
WITH_REQTIMEOUT=true
 
WITHOUT_CGID=true
 
# This file is auto-generated by 'make config'.
 
# No user-servicable parts inside!
 
# Options for apr-ipv6-devrandom-gdbm-db42-1.4.2.1.3.10
 
_OPTIONS_READ=apr-ipv6-devrandom-gdbm-db42-1.4.2.1.3.10
 
WITH_THREADS=true
 
WITHOUT_IPV6=true
 
WITH_BDB=true
 
WITH_GDBM=true
 
WITHOUT_LDAP=true
 
WITHOUT_MYSQL=true
 
WITHOUT_NDBM=true
 
WITHOUT_PGSQL=true
 
WITHOUT_SQLITE=true
 
WITH_DEVRANDOM=true
 
# This file is auto-generated by 'make config'.
 
# No user-servicable parts inside!
 
# Options for gd-2.0.35_7,1
 
_OPTIONS_READ=gd-2.0.35_7,1
 
WITHOUT_X11=true
 
WITHOUT_XPM=true
 
WITHOUT_FONTCONFIG=true
 
WITHOUT_ICONV=true
 
# This file is auto-generated by 'make config'.
 
# No user-servicable parts inside!
 
# Options for m4-1.4.15,1
 
_OPTIONS_READ=m4-1.4.15,1
 
WITHOUT_LIBSIGSEGV=true
 
# This file is auto-generated by 'make config'.
 
# No user-servicable parts inside!
 
# Options for p5-Class-C3-0.23
 
_OPTIONS_READ=p5-Class-C3-0.23
 
WITHOUT_XS=true
 
# This file is auto-generated by 'make config'.
 
# No user-servicable parts inside!
 
# Options for p5-HTML-Mason-1.45
 
_OPTIONS_READ=p5-HTML-Mason-1.45
 
WITHOUT_MOD_PERL=true
 
WITHOUT_APACHE2=true
 
# This file is auto-generated by 'make config'.
 
# No user-servicable parts inside!
 
# Options for p5-IO-Socket-SSL-1.37
 
_OPTIONS_READ=p5-IO-Socket-SSL-1.37
 
WITHOUT_IDN=true
 
WITHOUT_IPV6=true
 
# This file is auto-generated by 'make config'.
 
# No user-servicable parts inside!
 
# Options for p5-Log-Dispatch-2.28
 
_OPTIONS_READ=p5-Log-Dispatch-2.28
 
WITHOUT_APACHELOG=true
 
WITHOUT_EMAIL_MIMELITE=true
 
WITHOUT_EMAIL_MAILSEND=true
 
WITH_EMAIL_MAILSENDMAIL=true
 
WITHOUT_MAIL_SENDER=true
 
# This file is auto-generated by 'make config'.
 
# No user-servicable parts inside!
 
# Options for p5-Test-NoWarnings-1.02
 
_OPTIONS_READ=p5-Test-NoWarnings-1.02
 
WITHOUT_DEVEL_STACKTRACE=true
 
# This file is auto-generated by 'make config'.
 
# No user-servicable parts inside!
 
# Options for p5-libwww-5.837
 
_OPTIONS_READ=p5-libwww-5.837
 
WITH_SSL=true
 
# This file is auto-generated by 'make config'.
 
# No user-servicable parts inside!
 
# Options for perl-5.10.1_3
 
_OPTIONS_READ=perl-5.10.1_3
 
WITHOUT_DEBUGGING=true
 
WITHOUT_GDBM=true
 
WITHOUT_PERL_MALLOC=true
 
WITH_PERL_64BITINT=true
 
WITHOUT_THREADS=true
 
WITHOUT_MULTIPLICITY=true
 
WITHOUT_SUIDPERL=true
 
WITHOUT_SITECUSTOMIZE=true
 
WITHOUT_USE_PERL=true
 
# This file is auto-generated by 'make config'.
 
# No user-servicable parts inside!
 
# Options for png-1.4.5
 
_OPTIONS_READ=png-1.4.5
 
WITHOUT_APNG=true
 
# This file is auto-generated by 'make config'.
 
# No user-servicable parts inside!
 
# Options for portmaster-3.6
 
_OPTIONS_READ=portmaster-3.6
 
WITH_BASH=true
 
WITHOUT_ZSH=true
 
# This file is auto-generated by 'make config'.
 
# No user-servicable parts inside!
 
# Options for postgresql-server-9.0.2
 
_OPTIONS_READ=postgresql-server-9.0.2
 
WITH_NLS=true
 
WITHOUT_DTRACE=true
 
WITHOUT_PAM=true
 
WITHOUT_LDAP=true
 
WITHOUT_MIT_KRB5=true
 
WITHOUT_HEIMDAL_KRB5=true
 
WITHOUT_OPTIMIZED_CFLAGS=true
 
WITH_XML=true
 
WITH_TZDATA=true
 
WITHOUT_DEBUG=true
 
WITHOUT_GSSAPI=true
 
WITHOUT_ICU=true
 
WITH_INTDATE=true
 
# This file is auto-generated by 'make config'.
 
# No user-servicable parts inside!
 
# Options for python26-2.6.6
 
_OPTIONS_READ=python26-2.6.6
 
WITH_THREADS=true
 
WITHOUT_HUGE_STACK_SIZE=true
 
WITHOUT_SEM=true
 
WITHOUT_PTH=true
 
WITH_UCS4=true
 
WITH_PYMALLOC=true
 
WITHOUT_IPV6=true
 
WITHOUT_FPECTL=true
 
 
</pre>
 
</pre>
  
==2. Install perl modules outside of ports==
+
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.
  
I downloaded the following from the CPAN site:
+
==Install Freeside==
 +
 
 +
Fetch the Freeside tarball and unpack it:
  
 
<pre>
 
<pre>
Business-US-USPS-WebTools-1.11.tar.gz
+
cd /usr/local/src
Chart-2.4.2.tar.gz
+
fetch http://www.freeside.biz/freeside/freeside-2.1.1.tar.gz
Email-Sender-Transport-SMTP-TLS-0.09.tar.gz
+
tar xvzf freeside-2.1.1.tar.gz
HTML-Defang-1.04.tar.gz
 
Net-SMTP-TLS-ButMaintained-0.13.tar.gz
 
 
</pre>
 
</pre>
  
Unpack each, then cd to the directory and run "perl Makefile.pl". Look for any errors - if any dependancies are unsatisfied, that should be noted at the end of the outputOnce all dependencies are satisfied, run "make" and "make install".
+
The rest of this section is mostly copied directly from the normal [http://www.freeside.biz/mediawiki/index.php/Freeside:2.1:Documentation:Installation#Installation 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.
 +
 
 +
<pre>
 +
[ 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
 +
</pre>
 +
 
 +
=== 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.
 +
 
 +
<pre>
 +
DB_TYPE = Pg
 +
DB_USER = freeside
 +
DB_PASSWORD= supersecret
 +
DATASOURCE = DBI:${DB_TYPE}:dbname=freeside
 +
</pre>
 +
 
 +
=== Database ===
 +
 
 +
* Add the freeside database to Postgres:
 +
 
 +
<pre>
 +
[ As freeside user - "su freeside" ]
 +
$ createdb -E LATIN1 freeside
 +
</pre>
 +
 
 +
=== Freeside Perl Modules ===
 +
* Build and install the Perl modules:
 +
<pre>
 +
# cd /usr/local/src/freeside-2.1.1
 +
# gmake perl-modules
 +
# gmake install-perl-modules
 +
</pre>
 +
 
 +
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:
 +
<pre>
 +
#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
 +
</pre>
 +
 
 +
* Create the necessary configuration files and install them
 +
<pre>
 +
# gmake create-config
 +
</pre>
 +
 
 +
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:
 +
<pre>
 +
# gmake install-texmf
 +
</pre>
 +
 
 +
=== 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:
 +
<pre>
 +
# gmake install-docs
 +
</pre>
 +
* Ensure you have a populated /usr/local/www/freeside directory
 +
 
 +
* To install the apache configs, run:
 +
<pre>
 +
# gmake install-apache
 +
</pre>
 +
*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 <code>freeside-setup -d your.domain.name</code> to create the database tables and initial data.
 +
<pre>
 +
# su freeside
 +
$ freeside-setup -d example.com
 +
</pre>
 +
 
 +
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:
 +
<pre>
 +
# su freeside
 +
$ freeside-adduser -g 1 fs_queue
 +
$ freeside-adduser -g 1 fs_daily
 +
$ freeside-adduser -g 1 fs_selfservice
 +
</pre>
 +
 
 +
=== Create Freeside Users ===
 +
* Create one or more Freeside users (your internal sales/tech folks, not customer accounts):
 +
<pre>
 +
# su freeside
 +
$ freeside-adduser -g 1 username
 +
$ htpasswd /usr/local/etc/freeside/htpasswd username
 +
Password:
 +
</pre>
 +
 
 +
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 RTYou may find more missing perl modules here...
 +
 
 +
* Create a new Unix group called 'rt'
 +
<pre>pw groupadd rt2 -g 2002</pre>
 +
* Configure RT (in /usr/local/src/freeside-2.1.1
 +
<pre># make configure-rt</pre>
 +
* 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/
 +
<pre># make create-rt</pre>
 +
* ''Authentication errors?''
 +
** ''Edit <code>pg_hba.conf</code>, change "<code>ident sameuser</code>" auth to "<code>trust</code>" for the line starting with "<code>local all all</code>"''
 +
** ''Restart Pg''
 +
** ''Revert the change back and restart Pg after this installation step''
 +
*Install RT (configs? data? not sure)
 +
<pre><nowiki>make install-rt</nowiki></pre>
 +
* Follow the tail end of the RT install docs:  [[Freeside:1.9:Documentation:RT_Installation|install the integrated RT ticketing system]]
 +
 
 +
== Finalize ==
  
==3. Install Freeside==
+
* Restart Apache (httpd) and log into the web interface using the username and password you entered above.
 +
* Now proceed to the initial [[Freeside:1.9:Documentation:Administration|administration]] of your installation.

Latest revision as of 21:02, 8 January 2011

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.