Creating A Zotonic Blog
I have finally decided to start a blog, and rather than follow the masses, I decided not to use Wordpress.
Zotonic is a content management system brought to you by these clever fellows. If you are interested in Erlang but have not yet found something quick and practical that you can do with it to get you started, then Zotonic could be just what you are looking for. You can get started building sites with basically no experience of Erlang and then if you are feeling adventurous you could try to write a module in Erlang to extend it's already ample feature set.
The following is a guide to how I got this blog up and running on a cheap shared hosting package from Webfaction. I am sure there are plenty of other places you could run Zotonic, but Webfaction works for me. If you are installing somewhere else, you can ignore all the Webfaction specific stuff. If you want to sign up for an account with Webfaction, you can click here.
Once you have your Webfaction account, you can login via ssh.
Zotonic uses Mercurial for version control, so first you need to install mercurial, you can install it by doing this:
easy_install mercurial
Next create a directory called "Downloads", just somewhere to store all the stuff you need to fetch from the net, you can delete the entire directory as soon as your blog is running.
mkdir Downloads
Change to your new Downloads directory:
cd Downloads
Get the latest R13 version of Erlang from the Erlang website (R13B04 at time of writing):
wget http://www.erlang.org/download/otp_src_R13B04.tar.gz
Extract the archive:
tar -xvf otp_src_R13B04.tar.gz
Change to the newly extracted directory:
cd otp_src_R13B04
Compile Erlang:
./configure --prefix=/home/your_username make make install
Test Erlang:
erl
Type Ctrl+c followed by 'a' to exit erlang.
Install a newer version of ImageMagick:
wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
tar -xvf ImageMagick.tar.gz
cd ImageMagick
./configure --prefix=/home/yourusername make
make install
Type:
cd
to return to your home directory.
Check out the latest version of the Zotonic code:
hg clone https://zotonic.googlecode.com/hg/ zotonic
Change to the newly created zotonic directory:
cd zotonic
Now we need to log into the webfaction control panel to set up a port for Zotonic to use, and to create a database for zotonic.
Go to: https://panel.webfaction.com/
Login.
Go to: Domains/websites --> Applications
Click the the green '+' icon to create a new application. You will find this on the bottom left of the list of existing applications.
Put in 'zotonic' in the name field.
For App Type, choose 'Custom App (Listening on port)'
Click create.
When the app is created, it will tell you what port it will be listening on.
Note this port down, as you will need it for your Zotonic config.
Now, in the webfaction control panel again, go to: Domains/websites --> websites
Click the green '+' icon to add a new website.
For the name, enter 'zotonic'
Choose you sites domain (and sub-domains by using the control key)
Click the green '+' to add an application for this site.
Choose the 'zotonic' applcation from the dropdown.
Enter '/' as the path.
Click 'create'.
Again in the webfaction panel, go to Databases --> Create new database
Enter a database name and choose postgresql as the database type from the dropdown.
Click 'create'
The username will be the same as the database name. A password will be supplied to you.
Note these down for your zotonic configuration.
Now back at the command line:
nano priv/sites/default/config.in
Change the hostname to your domain name:
{hostname, "yourdomainname.com"},
Add an alias for www.yourdomain.com:
{hostalias, "www.yourdomainname.com"},
Change database details to match what you created in the webfaction panel:
{dbuser, "usernamehere"},
{dbpassword, "passwordhere"},
{dbdatabase, "dbnamehere"},
Save this config file.
Back at the command line type:
cp priv/sites/default/config.in priv/sites/default/config
Copy the zotonic.sh script from doc:
cp doc/zotonic.sh .
Open zotonic.sh and change the folowing:
BASE=/home/yourhomedirectory ZOTONIC_SH=$BASE/zotonic/zotonic.sh ERL="/home/yourhomedirectory/bin/erl"
And set the port to the number you were assigned by webfaction:
export ZOTONIC_PORT=8080
Save the file.
At the command line type (replacing the values for your zotonic database):
psql -U db_user -d db_database --password
Enter your password.
Type the following:
create LANGUAGE plpgsql;
Do Ctrl+d.
Run make:
make chmod u+x zotonic.sh ./zotonic debug
Comments
S.T.
Posted 1 year, 9 months ago.
Do you also have a feed?
Site Administrator
Posted 1 year, 9 months ago.
Indeed I do: http://michaelconnors.net/feed/text
S.T.
Posted 1 year, 9 months ago.
Ah, you have two link-alternate tags for application/atom+xml in the html's head, the first one with an empty href. This prevents google reader, for instance, from automatically discovering the feed.
Site Administrator
Posted 1 year, 9 months ago.
I have removed the extra link-alternate tag from my blog, and reported the issue to the zotonic guys.
Cillian de Róiste
Posted 1 year, 9 months ago.
Thanks for the very detailed howto! I've heard that Zotonic is very economical with resources so I guess you're not using caching or anything yet your blog seems quite snappy. Out of curiosity which hosting package are you using or rather how much "application memory" have you got, and are you also hosting other sites on the same server?
Ádh mór!
Michael
Posted 1 year, 9 months ago.
Hi Cillian,
I signed of for the package called "Shared 1" with Webfaction. This offers 80MB of application memory. I have 4 Zotonic sites, a Wordpress blog and 2 static sites on one account. I'm not finished yet though :-)
Cillian de Róiste
Posted 1 year, 9 months ago.
Amazing! Thanks!
jeff
Posted 1 year, 9 months ago.
Michael,
Thanks for the instructions - they worked great.
I would like to share one thing that I ran into with my webfaction installation though.
Images were not displaying due to an ImageMagick version coflict. After doing a make; make install of ImageMagick, I had to perform
1. Enter echo "export PATH=$HOME/bin:\$PATH" >> .bash_profile and press Enter.
2. Reload your .bash_profile. Enter source .bash_profile and press Enter.
3. cd zotonic; make clean; make
4. ./zotonic.sh start - Happy pictures now being displayed.
Just thought I'd share this for anyone that was missing this in their .bash_profile as well.
Thanks again for the post. 2 week into Erlang, Nitrogen, Zotonic and Riak and I'm loving it.
Jeff
Posted 1 year, 9 months ago.
Also,
Just wondering if you were able to get the smtp settings configured correctly?
Thanks,
Jeff
Michael
Posted 1 year, 9 months ago.
Hi Jeff, I did get smtp working. You need to set up an email box and address in webfaction, they won't send mail from an address they do not handle. If the mail for your domain is handled elsewhere, you will need to use that smtp server to send mail from zotonic too.
Here is the Zotonic documentation on configuring mod_mailer: http://zotonic.com/mod-emailer
Michael
Posted 1 year, 9 months ago.
btw, thanks for the fix above Jeff. As I recall, I did have to do this on the first account, I thought I had figured out a way around it for the second. I guess not.
Daniel
Posted 1 year, 9 months ago.
Thanks so much for documenting these steps to get going on webfaction. This should be a great help to others. I do think i have found a typo though.
Instead of "cp priv/sites/default/config.in priv/sites/default.config".
It should be "cp priv/sites/default/config.in priv/sites/default/config.
Thanks,
Daniel
Site Administrator
Posted 1 year, 9 months ago.
Thanks Daniel, well spotted. This is fixed now.
Daniel
Posted 1 year, 9 months ago.
In configuring the zotonic.sh script, what did you use for a "HOSTNAME" where it suggests a FQDN or localhost for an address? I have tried web131.webfaction and also localhost and 127.0.0.1 and none of these allow me to properly stop the process. I have to manually kill it.
Thanks,
Daniel
Daniel
Posted 1 year, 9 months ago.
I mean I tried "web131.webfaction.com"
Michael
Posted 1 year, 8 months ago.
Hi Daniel,
I left this as localhost and I had no problems.
ludovic
Posted 1 year ago.
Hi, i have a problem on zotonic/webfaction :
I can't see any images. The error happens with 'convert' command, whiche raises the following error :
unrecognizedLayerType flatten
i have copied the error dump in th zotonic shell and recreates the command, typed it in the command line andgot the same error.
As said in this topic ( http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=16967 ), the 'flatten' layer was added in the 6.3.2 version of ImageMagick.
when i launch 'convert --version' i get this:
Version: ImageMagick 6.2.8 10/20/10 [...]
So, i need another version.
But ! i build ImageMagick from source and the folder in the archive ImageMagick.tar.gz is named ImageMagick-6.6.9-8
So, did you have the same issues ? According to the download, the version builded has to be 6.6 and not 6.2
Thanks
Ludovic
Posted 1 year ago.
Ok, according to a previous post in this blog entry (wich i misread), the problem was that IM is already installed on webfaction.
I thought that the previous post explained that the /home/username/bin path was not set properly but the real point is that i have to invert the path order to have zotonic use my builded version.
Sorry for the flood :)
Bo
Posted 5 months, 26 days ago.
Marc,
It seems than now, Zotonic use git instead of hg (mercurial). So command "hg clone https://zotonic.googlecode.com/hg/ zotonic" becomes "git clone https://github.com/zotonic/zotonic.git".
B.