Run your own CardDAV server on Ubuntu using SOGo.
Finally, (!) I’ve become one step closer to having my information on cloud-computing. Now, my personal address book is stored on my private web-server, and I no longer have to worry about “syncing” all address books between my iPhone, laptop, Austin’s desktop and Houston’s desktop. (The beauty of cloud computing!)
This guide requires you to have apache pre-installed on your system.
Let’s get started. Go to your ubuntu server, and modify /etc/apt/sources.list — add the following line.
# these lines are for SOGo on Ubuntu. (Used for SOGo.) deb http://inverse.ca/ubuntu lucid main
If you’re on Maverick, use this instead:
# these lines are for SOGo on Ubuntu. (Used for SOGo.) deb http://inverse.ca/ubuntu maverick maverick
Then, install it.
sudo apt-get update; sudo apt-get upgrade; sudo apt-get install sogo apache2 libapache2-mod-proxy-html
The ‘update’ line is for APT to notice your new line in the sources.list file. The upgrade line is just in case you don’t have the latest libraries on your machine.
Now we enable some apache2 mods.
sudo a2enmod headers rewrite proxy_html proxy_http ssl sudo a2ensite default-ssl sudo /etc/init.d/apache2 restart
At this point, try visiting http://localhost/SOGo/. It should show you the SOGo page! Login doesn’t work yet, but we’ll fix that. If the SOGo page doesn’t show up, something went wrong. Post a comment with a description of the error you’re getting and we’ll try to get you back on the right track.
Now we need to configure some things. First things first — I did most of my configuration by following the documentation provided by SOGo. It’s not as long as you might think and is worth a read through! (I admit to skipping over the technical implementation details — I went straight to the instructions.)
After installing, go ahead and run the following commands to set some defaults:
sudo -s su - sogo defaults write sogod SOGoTimeZone "America/Montreal" defaults write sogod SOGoMailDomain "acme.com" defaults write sogod SOGoLanguage English defaults write sogod SOGoAppointmentSendEMailNotifications YES defaults write sogod SOGoFoldersSendEMailNotifications YES defaults write sogod SOGoACLsSendEMailNotifications YES defaults write sogod SOGoProfileURL mysql://sogo:sogopw@localhost:3306/sogo/sogo_user_profile exit /etc/init.d/apache2 restart /etc/init.d/sogo start exit
You should replace the timezone with your timezone, and the mail domain with your domain name. You can change any of the above values to “NO” if you want. For more information about what the keys are for, refer to the documentation.
Now that you’ve set up some basic stuff, let’s take care of authentication. Here I’ll be using authentication using MySQL. Setting up MySQL is outside the scope of this guide, but you can find many guides on how to do it just by googling around. Anyway, open up the .GNUstepDefaults file with your favorite text editor, and let’s take a look. I’m going to be using vim in this tutorial.
sudo vim /home/sogo/GNUstep/Defaults/.GNUstepDefaults
You’ll notice that it’s in XML, even though the one in the guide is in JSON. That’s because this is a gnustep property-list file, and the old standard was JSON but the new standard is XML. No matter, they represent identical things in this context so it’s not hard to follow the guide.
We’ll have to add a way for users to authenticate to SOGo. To do this, add the following section to your config file, inside the <dict> under <key>sogod</key>.
<key>SOGoUserSources</key> <array> <dict> <key>type</key> <string>sql</string> <key>id</key> <string>database</string> <key>canAuthenticate</key> <string>YES</string> <key>userPasswordAlgorithm</key> <string>md5</string> <key>viewURL</key> <string>mysql://sogo:sogopw@localhost:3306/sogo/sogo_auth</string> </dict> </array> <key>OCSFolderInfoURL</key> <string>mysql://sogo:sogopw@localhost:3306/sogo/sogo_folder_info</string>
Now, let’s configure the MySQL by creating the sogo user for MySQL. Issue the command:
mysql -u root -p
Use whatever password you configured your MySQL root with.
Now in MySQL, execute these queries:
CREATE USER 'sogo'@'localhost' IDENTIFIED BY 'sogopw'; CREATE DATABASE sogo CHARSET='UTF8'; GRANT ALL PRIVILEGES ON sogo.* TO 'sogo'@'localhost' WITH GRANT OPTION; USE sogo; CREATE TABLE sogo_auth (c_uid VARCHAR(256), c_name VARCHAR(256), c_password VARCHAR(256), c_cn VARCHAR(256), mail VARCHAR(256)); INSERT INTO sogo.sogo_auth VALUES('admin', 'admin', md5('admin_pw'), 'Admin Name', 'email@example.com'); FLUSH PRIVILEGES; EXIT
Replace the values for the insert query with anything you want. MySQL configuration is more-or-less done. Let’s move on to Apache.
sudo vim /etc/apache2/conf.d/SOGo.conf
Make changes to these lines:
RequestHeader set "x-webobjects-server-port" "443" RequestHeader set "x-webobjects-server-name" "yourhostname" RequestHeader set "x-webobjects-server-url" "https://yourhostname"
change “yourhostname” and “https://yourhostname” to your actual host name and URL. If you want to use SSL, keep the port number as “443″ and keep the “https://” section. Otherwise, use “80″ and “http://” instead.
Now we start SOGo and restart Apache.
sudo /etc/init.d/sogo restart sudo /etc/init.d/apache2 restart
You should now be able to login with admin // admin_pw at http://localhost/SOGo/.