Hi guys. Finally this is it.
This guide will walk through the installation of SOGo 1.3.4 on FreeBSD 8.0/8.2 I make the assumption that you have a mail server running with some sort of database auth like Mysql, PosgreSQL or LDAP. In my setup I have Postfixadmin, Postfix, Dovecot and Mysql so the example for the auth process is base on Mysql auth. If you need information on how to use LDAP auth there is a lot of detailed documentation on the SOGo page and is easy to set up than Mysql/PgSQL ( in my opinion ,for the lack of documentation and examples) 1.- Just so everyone knows that I started from a blank jail. sogo# pkg_info pkg_info: no packages installed 2.- I edit and add entries to my resolv.conf to have DNS resolve. nameserver ipofyournameserver 3.- Now I will install bash user portmanager so I can get some basic dependencies : sogo# cd /usr/ports/ports-mgmt/portmanager/ sogo# make install clean distclean sogo# tcsh sogo# portmanager shells/bash And continue with the install process until is done. 4.- we switch to bash and we update the locate db sogo# /usr/libexec/locate.updatedb 5.- Installing some SOGo dependencies sogo# portmanager devel/gnustep sogo# portmanager databases/mysql51-client sogo# portmanager net/openldap24-server ( if you are going to set up LDAP sever in the same server) sogo# portmanager databases/libmemcached sogo# portmanager devel/monotone sogo# portmanager www/nginx 6.- Create the user sogo and then run : sogo# su -l sogo sogo# mtn db init --db=~/db.mtn sogo# mtn --db=~/db.mtn pull inverse.ca ca.inverse.sope sogo# mtn --db=~/db.mtn checkout --branch ca.inverse.sope SOPE sogo# mtn --db=~/db.mtn pull inverse.ca ca.inverse.sogo sogo# mtn --db=~/db.mtn checkout --branch ca.inverse.sogo SOGo At this point I did a snapshot of the jail just in case I screw up some libraries and such….:) 7.- ok so now the fun starts, let's try to install SOPE change the first line one of configure script to #!/usr/local/bin/bash or /bin/sh change this line too : LINK_SYSLIBDIRS="-L/usr/local/lib/mysql -L/usr/local/pgsql/lib -L/usr/local/lib -L/usr/lib" if you are using postgress and add the path to the libs here too. now we have to source the GNUstep.sh file sogo# source /usr/local/GNUstep/System/Library/Makefiles/GNUstep.sh ( read the GNUstep.sh file for more information ). sogo# cd SOPE sogo# ./configure --with-gnustep --enable-debug --disable-strip ... ... ... GNUstep environment: system: /usr/local/GNUstep/System local: /usr/local/GNUstep/Local user: /root/GNUstep path: /usr/local/GNUstep/System:/usr/local/GNUstep/Network:/usr/local/GNUstep/Local:/root/GNUstep flat: yes arch: amd64-portbld-freebsd8.0 combo: gnu-gnu-gnu Note: will install in GNUSTEP_LOCAL_ROOT: /usr/local/GNUstep/Local Configuration: FHS: install in GNUstep tree debug: yes strip: no prefix: /usr/local/GNUstep/Local frameworks: gstep: /usr/local/GNUstep/System/Library/Makefiles config: /home/sogo/SOPE/config.make script: /usr/local/GNUstep/System/Library/Makefiles/GNUstep.sh creating: /home/sogo/SOPE/config.make optional library found: xml2 optional library found: ldap required library found: ssl failed to link optional library: pq failed to link optional library: mysqlclient configuring NGStreams library .... done (log in config-NGStreams.log). Base on http://mail.opengroupware.org/pipermail/users/2006-August/016620.html and http://www.mail-archive.com/users@sogo.nu/msg03000.html you can pretty much ignore the error that it can't find mysql or pg libraries you can run make with the following parameter and it will compiled with support for mysql or pg. sogo# gmake HAS_LIBRARY_pq=yes sogo# gmake HAS_LIBRARY_mysqlclient=yes as you can see in the output of make : Making all in MySQL ... Making all for bundle MySQL... Creating MySQL.gdladaptor/.... Compiling file MySQL4Expression.m ... Compiling file MySQL4Adaptor.m ... Compiling file MySQL4Context.m ... Compiling file MySQL4Channel.m ... Compiling file MySQL4Channel+Model.m ... Compiling file MySQL4Exception.m ... Compiling file MySQL4Values.m ... Compiling file NSString+MySQL4.m ... Compiling file EOAttribute+MySQL4.m ... Compiling file NSString+MySQL4Val.m ... Compiling file NSData+MySQL4Val.m ... Compiling file NSCalendarDate+MySQL4Val.m ... Compiling file NSNumber+MySQL4Val.m ... Linking bundle MySQL ... Creating MySQL.gdladaptor/Resources... Copying resources into the bundle wrapper... Creating stamp file... Creating MySQL.gdladaptor/Resources/Info-gnustep.plist... it actually works!!!! sogo# gmake install 8.- Now the real fun begins….will SOGo compile ???? sogo# cd ../SOGO We need to change the first line of configure script like we did for sope. We need to change the LINK_SYSLIBDIR accordingly as we did for SOPE (-L/usr/local/lib/mysql or pg ) sogo# ./configure --enable-debug --disable-strip sogo# ./configure --enable-debug --disable-strip GNUstep environment: system: /usr/local/GNUstep/System local: /usr/local/GNUstep/Local user: /root/GNUstep path: /usr/local/GNUstep/System:/usr/local/GNUstep/Network:/usr/local/GNUstep/Local:/root/GNUstep flat: yes arch: amd64-portbld-freebsd8.0 combo: gnu-gnu-gnu Note: will install in GNUSTEP_LOCAL_ROOT: /usr/local/GNUstep/Local Configuration: debug: yes strip: no ldap-based configuration: no prefix: /usr/local/GNUstep/Local gstep: /usr/local/GNUstep/System/Library/Makefiles config: /usr/home/sogo/SOGo/config.make script: /usr/local/GNUstep/System/Library/Makefiles/GNUstep.sh creating: /usr/home/sogo/SOGo/config.make now we need to modify the GNUmakefile.postamble file that has options for cp command that are not compatible with FreeBSD cp. sogo## sed -i.back 's/-dpR/-a/g' SOPE/NGCards/GNUmakefile.postamble and now…. sogo# gmake install if you don't see any more errors you are almost there, now the service configuration and nginx configs part begins : 9.- nginx virtual host config server { listen 80; server_name sogo.example.com 10.0.0.58; (ip or FQDN name of you soggy virtual host) access_log /var/log/sogo-access.log main; error_log /var/log/sogo-error.log info; client_max_body_size 50m; location /usr/local/GNUstep/Local/Library/SOGo/ { if (-f $request_filename) { expires max; break; } } #location ^~ /SOGo/ { ( if you want your url like mail.example.com/SOGo/) location ^~ / { ( if you want mail.example.com) (see sogo docs for more info about this parameter) proxy_pass http://10.0.0.58:20000/SOGo; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_set_header x-webobjects-remote-host 10.0.0.58; proxy_set_header x-webobjects-server-protocol HTTP/1.0; proxy_set_header x-webobjects-server-name sogo.example.com; proxy_set_header x-webobjects-server-port 80; proxy_set_header x-webobjects-server-url http://sogo.example.com:7777; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; client_max_body_size 50m; client_body_buffer_size 128k; break; } location /.woa/WebServerResources/ { alias /usr/local/GNUstep/Local/Library/SOGo/WebServerResources/; } location /SOGo.woa/WebServerResources/ { alias /usr/local/GNUstep/Local/Library/SOGo/WebServerResources/; } location /SOGo/WebServerResources/ { alias /usr/local/GNUstep/Local/Library/SOGo/WebServerResources/; } location ^/SOGo/so/ControlPanel/Products/([^/]*)/Resources/(.*)$ { alias /usr/local/GNUstep/Local/Library/SOGo/$1.SOGo/Resources/$2; } } 10.- now you have to use this start up script to run sogo ( courtesy of Euan Thoms ): copy this to /usr/local/etc/rc.d make it executable and add sogod_enable="YES" on your /etc/rc.conf #!/bin/sh # # # PROVIDE: sogod # REQUIRE: memcached # # Add the following lines to /etc/rc.conf to enable sogod: # # sogod_enable (bool): Set it to "YES" to enable sogod. # Default is "NO" # # . /etc/rc.subr name="sogod" rcvar=`set_rcvar` load_rc_config ${name} : ${sogod_enable="NO"} : ${sogod_user="sogo"} : ${sogod_group="sogo"} : ${sogod_workers="-WOWorkersCount 1"} : ${sogod_command="/usr/local/GNUstep/Local/Tools/Admin/sogod"} : ${sogod_logfile="/var/log/sogo/sogo.log"} pidfile="/var/run/sogo/sogo.pid" command="/usr/sbin/daemon" command_args="-p ${pidfile} -u ${sogod_user} ${sogod_command} ${sogod_workers} -WOPidFile ${pidfile} -WOLogFile ${sogod_logfile}" start_precmd="sogod_prestart" start_cmd="sogod_start" stop_cmd="sogod_stop" status_cmd="sogod_status" sogod_prestart() { if [ ! -d `dirname ${pidfile}` ]; then mkdir `dirname ${pidfile}` && chown ${sogod_user}:${sogod_group} `dirname ${pidfile}` fi if [ ! -d `dirname ${sogod_logfile}` ]; then mkdir `dirname ${sogod_logfile}` touch ${sogod_logfile} && chown ${sogod_user}:${sogod_group} ${sogod_logfile} fi if [ -z ${GNUSTEP_SYSTEM_ROOT} ]; then . /usr/local/GNUstep/System/Library/Makefiles/GNUstep.sh fi } sogod_start () { ${command} ${command_args} } sogod_stop () { kill `cat ${pidfile}` } sogod_status () { if [ -f ${pidfile} ]; then echo "${name} is running as pid `cat ${pidfile}`" else echo "${name} is not running" fi } run_rc_command "$1" 11.- You have to create a compatible SOGo mysql view of your users database to allow SOGo to query using c_uid, c_name, c_password etc ( SOGo doesn't support md5crypt (yet) so you password must be stored using MD5 only otherwise is not going to work) in my case this is the postfix db used by postfixadmin so the view will look like : USE postfix; CREATE VIEW sogo_auth_view AS SELECT username AS c_uid, username AS c_name, password AS c_password, username AS c_cn, username AS mail, name AS displayName FROM mailbox WHERE active=1; 12.- Now if you don't have an existing mysql table with users then you can create one like : CREATE DATABASE sogo; USE sogo CREATE TABLE IF NOT EXISTS `sogo_users` ( `c_uid` varchar(32) CHARACTER SET utf8 NOT NULL DEFAULT '', `c_name` varchar(32) CHARACTER SET utf8 NOT NULL DEFAULT '', `c_password` varchar(250) CHARACTER SET utf8 NOT NULL DEFAULT '', `c_cn` varchar(250) CHARACTER SET utf8 NOT NULL DEFAULT '', `c_mail` varchar(250) CHARACTER SET utf8 NOT NULL DEFAULT '', UNIQUE KEY `c_uid` (`c_uid`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ; You will need to populate this db in order to test sogo. 13.- Now we need to populate the .GNUDefault for SOGo : sogo# su -l sogo sogo# source /usr/local/GNUstep/System/Library/Makefiles/GNUstep.sh sogo# defaults write sogod SOGoTimeZone "America/Vancouver" sogo# defaults write sogod SOGoMailDomain "example.com" sogo# defaults write sogod SOGoLanguage English sogo# defaults write sogod SOGoAppointmentSendEMailNotifications YES sogo# defaults write sogod SOGoFoldersSendEMailNotifications YES sogo# defaults write sogod SOGoACLsSendEMailNotifications YES sogo# defaults write sogod SOGoMemcachedHost 10.0.0.58 ( you could have memcache running on localhost too) sogo# defaults write sogod SOGoPasswordChangeEnabled YES ### For Mysql auth defaults write sogod SOGoUserSources '({ type = "sql"; id = "directory"; viewURL = "mysql://sogo:sogopass@10.0.0.56:3306/postfix/sogo_auth_view"; canAuthenticate = YES; isAddressBook = YES; userPasswordAlgorithm = md5; })' defaults write sogod SOGoProfileURL 'mysql://sogo: mysqlpassword@localhost:3306/sogo/sogo_user_profile' defaults write sogod OCSFolderInfoURL 'mysql://sogo: mysqlpassword@localhost:3306/sogo/sogo_folder_info' defaults write sogod SOGoMailingMechanism smtp defaults write sogod SOGoSMTPServer 10.0.0.56 defaults write sogod SOGoDraftsFolderName INBOX/Drafts defaults write sogod SOGoSentFolderName INBOX/Sent defaults write sogod SOGoTrashFolderName INBOX/Trash defaults write sogod SOGoOtherUsersFolderName "Other Users" defaults write sogod SOGoSharedFolderName "Shared Folders" defaults write sogod SOGoIMAPServer imap://10.0.0.56:143 defaults write sogod SOGoMailingMechanism smtpcd defaults write sogod SOGoSieveServer sieve://10.0.0.56 defaults write sogod SOGoVacationEnabled YES defaults write sogod SOGoForwardEnabled YES defaults write sogod SOGoSieveScriptsEnabled YES If you want to enable full debug in case of problem run this : defaults write sogod GCSFolderDebugEnabled YES defaults write sogod GCSFolderStoreDebugEnabled YES defaults write sogod LDAPDebugEnabled YES defaults write sogod NGImap4DisableIMAP4Pooling YES defaults write sogod OCSFolderManagerSQLDebugEnabled YES defaults write sogod PGDebugEnabled YES defaults write sogod SOGoDebugRequests YES defaults write sogod SOGoMailKeepDraftsAfterSend YES defaults write sogod SOGoUIxDebugEnabled YES defaults write sogod SoDebugObjectTraversal YES defaults write sogod SoSecurityManagerDebugEnabled YES defaults write sogod WOApplicationRedirectURL YES defaults write sogod WODontZipResponse YES defaults write sogod WODebugZipResponse YES Here is the xml configuration of the SOGoUserSources <key>SOGoUserSources</key> <array> <dict> <key>canAuthenticate</key> <string>YES</string> <key>id</key> <string>directory</string> <key>isAddressBook</key> <string>YES</string> <key>type</key> <string>sql</string> <key>userPasswordAlgorithm</key> <string>md5</string> <key>viewURL</key> <string>mysql://sogo:sogopass@10.0.0.56:3306/postfix/sogo_auth_view</string> </dict> </array> 14.- No you can start sogod /usr/local/etc/rc.d/sogod start And this is it, I was able to log in SOGo without any problems. There is a log file in /var/log/sogo.log. Now I'm working in SOGo on Apache, Gosa, Funanbol and Openchange in Freebsd. Please feel free to email me suggestions or comments about this guide so we can keep one good guide for installing SOGo on FreeBSD and not 10 of them with different installation methods. I will try to keep this guide up to date. Thanks Jose Amengual -- users@sogo.nu https://inverse.ca/sogo/lists