mycroes

There's always time to play

Tuesday, April 6, 2010

Installing Alfresco 3.3 on Ubuntu Lucid Lynx LTS (10.04)

I happily reused my previous installing Alfresco post to provide you with a new post detailing the setup of the forthcoming Alfresco release on the forthcoming Ubuntu release.

I'm still trying to figure a proper way to format content, but it should be readable at all times.

Note that lines starting with a # (in typable commands) mean they should be executed as root. There's many ways to do this, my advice would be to prepend the commands with sudo. I'm trying to visually distuingish everything you need to type yourself (as opposed to shell output or existing file contents), but I'm human so I will make mistakes every now and then. Quick tip: if you can't write a file from vim because you opened as non-root, use :w !sudo tee % to write the file using sudo.

Start with updating your system:
# apt-get update


Install Tomcat, MySQL and mysql-connector:
# apt-get install tomcat6 mysql-server libmysql-java


Edit /etc/default/tomcat6:
...
JAVA_OPTS="${JAVA_OPTS} -XX:+UseConcMarkSweepGC"
JAVA_OPTS="${JAVA_OPTS} -Xms512m -Xmx512m"
...

In contrary to in Ubuntu 9.04, the Tomcat security manager is disabled by default in 10.04. I guess this means that the security manager is more of a problem than a solution, so I'm already feeling better about not using it.

Create the Alfresco directory tree:
# mkdir /opt/alfresco
# cd /opt/alfresco
# wget http://dev.alfresco.com/downloads/nightly/dist/alfresco-community-war-3.3.tar.gz
# tar xf alfresco-community-war-3.3.tar.gz

You can use something else instead of /opt, but it seems to me this is a desirable location.

I consider myself somewhat experienced with Alfresco, so I'm not downloading the sample extensions...

Create Alfresco database and user:
$ mysql -u root -p < extras/databases/mysql/db_setup.sql


Create Alfresco and Tomcat directories:
# mkdir -p /srv/alfresco/alf_data
# mkdir -p /var/lib/tomcat6/shared/classes

I'm using /srv as data root, I should also move the shared/classes to that location. In my previous guide I used /var/lib/tomcat6/shared/lib/ as base for additional JARs (in this case the mysql-connector), but the default config assumes that these JARs reside in /var/lib/tomcat6/shared/, so I'm not going to deviate from that assumption.

Add links to war files to tomcat webapps:
# ln -s /opt/alfresco/alfresco.war /var/lib/tomcat6/webapps/
# ln -s /opt/alfresco/share.war /var/lib/tomcat6/webapps/


Add mysql connector to path where tomcat finds it:
# ln -s /usr/share/java/mysql-connector-java.jar /var/lib/tomcat6/shared/


Setup Alfresco global settings:
# cp /opt/alfresco/extensions/extension/alfresco-global.properties /var/lib/tomcat6/shared/classes/


Edit the just copied file:
...
#dir.root=./alf_data
dir.root=/srv/alfresco/alf_data
...



It seems that in some cases it's necessary to also include the hibernate dialect in this config file. You can do so by adding the following line:
...
hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect



Create the Alfresco extension root:
# mkdir -p /var/lib/tomcat6/shared/classes/alfresco/extension/

This directory is used to override alfresco configuration without changing the deployed WAR.

Setup logging in /var/lib/tomcat6/shared/classes/alfresco/extension/custom-log4j.properties:
log4j.rootLogger=error, File

log4j.appender.File=org.apache.log4j.DailyRollingFileAppender
log4j.appender.File.File=/var/log/tomcat6/alfresco.log
log4j.appender.File.Append=true
log4j.appender.File.DatePattern='.'yyyy-MM-dd
log4j.appender.File.layout=org.apache.log4j.PatternLayout
log4j.appender.File.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c] %m%n


Make sure permissions are reasonable:
# chown -R tomcat6:tomcat6 /var/lib/tomcat6 /srv/alfresco


Restart Tomcat and enjoy!
# /etc/init.d/tomcat6 restart


Now you should be able to reach Alfresco on [ip]:8080/alfresco and Alfresco Share on [ip]:8080/share.

37 comments:

Scotty said...

Hi Mike,

This is exactly what I was looking for - thankyou very much for making this available, Alfresco is not the most straightforward of apps to understand how to install/configure for someone with little knowledge of a tomcat based setup. I have now managed to install Alfresco 3.3 on lucid server, and migrate my previous repository from an ubuntu 9.04 / alfresco 3.2 setup by copying the alf_data folders and mysql db.

I can now access the web portal no problem, as well as the web share portal - but I am struggling to connect a user via CIFS - could you help? When I attempt to map the drive from a windows 7 pc to \\alf\alfresco or \\alf:8080\alfresco (alf being my server), I cannot connect. This is also true if I try to connect via ip address rather than machine name.

Thanks Michael,

Scott Donnelly

Michael Croes said...

Hi Scott,

First of all, thanks for the kind words and appreciation.

To test CIFS I'd suggest to try a Windows 2000 or XP host first. I don't know how complete the CIFS implementation in Alfresco is, but you might be more lucky with a bit older Windows client. Also, the 8080 port number is unrelated to CIFS, so that's one thing that definately won't work.

In did have CIFS working at a time with Alfresco 3.2r2, however host announce didn't seem to be working and I'm not gonna use CIFS in production.

I doubt these answers are enough to solve your issues, however you'd be better off asking this on the Alfresco forums. Just leave the link here and I'll also try to help you out there!
Regards,

Michael

P.s. I didn't have any Tomcat knowledge either, but I invested time to learn and make my knowledge available.

David said...

Thanks for posting this Mike, it was a big help. I'm new to Alfresco so my head is still swimming, but at least with the help of your notes I was able to get the damn thing up and running :-D

Scott, regarding CIFS, I put the following in my alfresco-global.properties:

cifs.enabled=true
cifs.serverName=
cifs.tcpipSMB.port=1445
cifs.netBIOSSMB.sessionPort=1139
cifs.netBIOSSMB.namePort=1137
cifs.netBIOSSMB.datagramPort=1138
ftp.enabled=false

I then use NATing (as suggested in Alfresco docs) to connect the ports above to the ports that are actually used by Windows:

modprobe iptable_nat
iptables -F
iptables -t nat -F
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -t nat -A PREROUTING -p tcp --dport 445 -j REDIRECT --to-ports 1445
iptables -t nat -A PREROUTING -p tcp --dport 139 -j REDIRECT --to-ports 1139
iptables -t nat -A PREROUTING -p udp --dport 137 -j REDIRECT --to-ports 1137
iptables -t nat -A PREROUTING -p udp --dport 138 -j REDIRECT --to-ports 1138

Once that's done (and tomcat is restarted, of course) I can go to \\server and I am prompted for a username/password.

Hope that helps! (I seem to be able to connect from OS X 10.5 and Windows 7, but not 10.6 (Snow Leopard).

Scotty said...

Hi Mike / David,

Thanks for the tips, I managed to get it up and running via IPtables port redirection using the same technique that David mentioned. I can now connect from XP/Vista/7, and can save and oad from Office '07 under Vista/7 which I could not do so before on 3.2, so thanks for the help.

Scott

Michael Croes said...

@Scott You're welcome, good to hear it's working now. I haven't done any Office integration yet, but I'm definately gonna do that too at some point.
Regards,

Michael

Alex The Blogger said...

Hallo Mike...

I've been trying to install alfresco the whole day... I tried every single method I found. I also did what your post says... everything... and I still get the same error 404. I had already installed apache and msql.. so i dont know if it makes any trouble... can u please help me? thanks a lot in advance...

Michael Croes said...

Hi Alex,

Apache should be unrelated, do keep in mind that tomcat runs on port 8080 by default (so ommitting the :8080 in the url will give a 404!).

Be sure to check the log files. If there's a /var/log/tomcat6/alfresco.log, look in that one and see if there's an issue (if there is, it's probably at the end of the file). If that file doesn't exist, check /var/log/tomcat6/catalina.log or /var/log/tomcat6/localhost.log.

With the information you've given so far I'm not able to give you any real help. If you could create a forum topic on the Alfresco forums with contents of those log files (or maybe even more information) and leave the link here I'll be sure to check it out.
Regards,

Michael

Alex The Blogger said...

Thanks Mike...
here tha link
http://forums.alfresco.com/en/viewtopic.php?f=8&t=26753

Stu said...

Excellent guide!!! Too bad it didn't work for me.

http://My-IP-Address:8080/alfresco gives me a generic Apache Tomcat 404 error

http://My-IP-Address:8080/share
gives me a 500 error with an exception report with a bunch of lines referring to "org.springframework.extensions.surf.(etc...)"

Maybe my system is missing something? I statred with a barebones Lucid OS simply added Java with "apt-get install sun-java6-jdk"

Any hints about where to look?

Michael Croes said...

Hi Stu,

As for where to look: /var/log/tomcat6/alfresco.log
/var/log/tomcat6/catalina.log

Also, I'm not using sun-jdk, but openjdk. I don't know if sun-jdk has any issues, but it could be.

I created the guide a while ago, before Lucid was released, if I find some time I'll be sure to check if everything still works with current Lucid.

Anyway, check those log files and please report back, I hope I can fix your issue! (also keep in mind that just this morning I added information about setting the hibernate dialect.)
Regards,

Michael

Stu said...

Thanks Michael,

So I switched to OpenJDK and got the same error. I checked the alfresco.log and discovered an UnknownHostException which led to "Unable to set localhost. This prevents creation of a GUID"

At that point I checked my /etc/hosts file and put in a line with my ip FQDN and hostname. Then I ran the following commands:

/etc/init.d/hostname restart
/etc/init.d/mysql restart
/etc/init.d/tomcat6 restart

The same error shows up in the logs after all of that. Do you know where alfresco goes to reslove names?

Thanks in advance.

Stu said...

Problem solved ... I changed my hostname to the FQDN and rebooted. I have no idea why it didn't resovle via the /etc/hosts file but this works.

Michael Croes said...

Good to see it's solved!

Pauli Price said...

Thank you for this tutorial, it was a great help. I still need to work out filesystem configuration, and openoffice, imagemagick, pdf2swf, installs. But wanted to share my changes.

Alfresco nightly 3.3 has moved to 'g' so the wget and untar have become:

# wget http://dev.alfresco.com/downloads/nightly/dist/alfresco-community-war-3.3g.tar.gz
# tar xf alfresco-community-war-3.3g.tar.gz

I'm setting up on Ubuntu 9.10, maybe that's why I had to override the security as per your previous write-up.

#TOMCAT6_SECURITY="yes"
TOMCAT6_SECURITY="no"

The hibernate.dialect setting was not being applied and I couldn't figure out why. I found the following statement on the wiki: http://wiki.alfresco.com/wiki/Repository_Configuration#alfresco-global.properties_.28V3.2.2B.29

"As of version V2.1-A and V3.1, the beans that load the Repository and Hibernate properties will give preferential treatment to any JVM-set properties. So rather than using alfresco-global.properties or the older mechanisms documented above, you may set properties directly as arguments to the JVM."

So I set it in the tomcat configuration file, /etc/default/tomcat6:
...
JAVA_OPTS="${JAVA_OPTS} -Dhibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect

And I was finally able to move past that error.

The sql connection was rejected. Suspecting that the credentials were not being picked up from the custom-alfresco.properties file, I researched further.

Found the 'Install Tomcat6' page on the wiki: http://wiki.alfresco.com/wiki/Install_Tomcat6 and saw that that the /var/lib/tomcat6/conf/catalina.properties file needed to be edited:

#shared.loader=
shared.loader=${catalina.base}/shared/classes,${catalina.base}/shared/lib/*.jar

Once that was done, I still couldn't connect to the database. But at least it explained why the hibernate.dialect setting wasn't being respected.

I then suspected the mysql configuration.

The bind-address in /etc/mysql/my.cnf was set to 127.0.0.1

I changed the bind-address to my FQDN, and changed my custom-alfresco.properties db.host value consistently. Didn't work.

I changed the bind-address to my outward facing IP, and changed my custom-alfresco.properties db.host value consistently. Didn't work.

I removed the bind-address directive, and restored the db.host value to localhost. Didn't work.

I restored the bind-address to 127.0.0.1 and set the db.host value to the same. It worked!!

Michael Croes said...

Thanks for your long comment. I did an install on Ubuntu 9.10 myself too, I ended up combining parts from both my guids in order to get it working. I'm amazed how there's so much trouble with the database setup for everyone, that's one of the things that has always just worked for me...

Before you start your openoffice journey: you'll need the openoffice.org package (which would seem like it's a desktop package) or you'll miss all the stuff that makes openoffice errr... openoffice.
Regards,

Michael

Pauli Price said...

I've got it running -- with some remaining warnings, and the RSS feed dashlet in share needs to be sorted -- but both alfresco load and admin can log in, and tomcat stays up.


sudo apt-get install openoffice.org-writer
sudo apt-get install openoffice.org-calc
sudo apt-get install openoffice.org-impress
sudo apt-get install openoffice.org-java-common

echo Updating system...
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install build-essential
sudo apt-get install curl libcurl4-openssl-dev
sudo apt-get install zlib1g-dev libssl-dev libexpat1-dev

wget http://swftools.org/swftools-0.9.0.tar.gz
tar -zvxf swftools-0.9.0.tar.gz
wget http://www.ijg.org/files/jpegsrc.v7.tar.gz
tar -zvxf jpegsrc.v7.tar.gz
wget http://download.savannah.gnu.org/releases-noredirect/freetype/freetype-2.3.12.tar.gz
tar -zvxf freetype-2.3.12.tar.gz

cd jpeg-7
sudo ./configure
sudo make
sudo make install

cd freetype-2.3.12
rm -f config.cache
sudo ranlib /usr/local/lib/libjpeg.a
sudo ldconfig /usr/local/lib
sudo LDFLAGS="-L/usr/local/lib" CPPFLAGS="-I/usr/local/include" ./configure
sudo make
sudo make install

sudo apt-get install xpdf-reader

cd swftools-0.9.0
sudo LDFLAGS="-L/usr/local/lib" CPPFLAGS="-I/usr/local/include" ./configure
sudo make

if you have these errors you have the new and improved, and pickier gcc 4.4 compiler. A minor source code edit fixes it's complaints.

GFXOutputDev.cc: In function ‘void addGlobalFont(const char*)’:
GFXOutputDev.cc:2507: error: invalid conversion from ‘const char*’ to ‘char*’
GFXOutputDev.cc:2508: error: invalid conversion from ‘const char*’ to ‘char*’

(you won't see this next one until you fix the first one)

pdf.cc: In function ‘gfxdocument_t* pdf_open(gfxsource_t*, const char*)’:
pdf.cc:450: error: invalid conversion from ‘const char*’ to ‘char*’


edit lib/pdf/GFXOutputDev.cc -- lines 2507 & 2508, insert an explicit cast to make gcc 4.4 happy
//char*r1 = strrchr(filename, '/');
//char*r2 = strrchr(filename, '\\');
char*r1 = strrchr((char *)filename, '/');
char*r2 = strrchr((char *)filename, '\\');

edit lib/pdf/pdf.cc -- line 450, insert an explicit cast to make gcc 4.4 happy
//if((x = strchr(filename, '|'))) {
if((x = strchr((char *)filename, '|'))) {

sudo make
sudo make install


update custom-alfresco.properties with external locations, and turn off unwanted file system features -- at least for now:

#
# External locations
#-------------
ooo.exe=/usr/bin/soffice
ooo.enabled=true
img.root=/usr
swf.exe=/usr/local/bin/pdf2swf

#
# Filesystems
#-------------
cifs.enabled=false
ftp.enabled=false
nfs.enabled=false


With the inclusion of the supporting software, soffice, pdf2swf, etc. The memory required is increased. The following, suggested on a forum post, eliminated my out of memory error.

Edit /etc/default/tomcat6:

...

JAVA_OPTS="${JAVA_OPTS} -Xms256m -Xmx1024m -Xss96k -XX:MaxPermSize=256m"

Pauli Price said...

Of course, I left out a step right at the beginning of that second part:

sudo apt-get install imagemagick


Had to post back, just so someone's following along won't end up pulling their hair out.

Michael Croes said...

I can only say thanks to that. Well done.

I believe I installed swftools from a deb, don't know if it's still in 9.10 or if I used the 9.04 deb, but it works fine (except for the fact that swftools is broken by design, that's why it's not in the repositories anymore).

Also for your RSS reader errors, that probably involves the js.jar file I mention somewhere near the bottom of my Alfresco on 9.04 writeup: because of rhino there's a JAR that gets used instead of Alfresco's bundled JAR, causing XML related errors.

If you ever write a blog post yourself concerning Alfresco (or another interesting detailed guide) please let me know, I would love to create a network of blogs with people who know how to solve problems and can properly publish their solution.
Regards,

Michael

Pauli Price said...

I am delighted to report that the Rhino jar was indeed the problem with the RSS feed dashlet.

sudo mv /usr/lib/jvm/java-6-openjdk/jre/lib/rhino.jar /usr/lib/jvm/java-6-openjdk/jre/lib/rhino.jarxxx

and a

sudo /etc/init.d/tomcat6 restart

And the dashlet happily pulling RSS feeds for public consumption. Happy Dance!

Any idea why /var/lib/tomcat6/shared/classes/custom-log4j.properties isn't being respected? I had to run find to locate the alfresco log. It ended up here:

/tmp/tomcat6-temp/alfresco.log

I'm trying to 'worry about it later' so I can move on with my project -- but it is gnawing at me. Very provoking!

As for my blog -- most likely I'll add some Alfresco posts over time. Here's the URL: http://RiverdaleStation.net

Pauli Price said...

Figured it out. custom-log4j.properties got here:

/var/lib/tomcat6/shared/classes/alfresco/extension/custom-log4j.properties

not here:

/var/lib/tomcat6/shared/classes/custom-log4j.properties

and we're good.

Michael Croes said...

I knew that one, have it working myself, but apparently made a mistake writing the blog post, thanks for letting me know!
Regards,

Michael

Anonymous said...

Hi Mike,
I am unable to find custom-log4j.properties in any location am I supposed to create it?

Unknown said...
This comment has been removed by the author.
Michael Croes said...

@wireyou:
Yes, you need to create it! Please come again if you need more help.
Regards,

Michael

Martin said...

Perfect, works!

BUT:

Setup logging in /var/lib/tomcat6/shared/classes/extension/custom-log4j.properties:

should be


Setup logging in /var/lib/tomcat6/shared/classes/alfresco/extension/custom-log4j.properties:

Michael Croes said...

Thanks Martin! I keep messing that line up, at least now it should be complete.
Regards,

Michael

Anonymous said...

A way to solve the CIFS problem without iptables could be to use lucid's authbind package.

From what I understand it is normally not possible for a user except root to server ports below 1024 (yes, I know that apache etc. do this). If you run tomcat as root it can access lower ports but that is not what we want.

According to the blog entry "Tomcat improvements coming up in 10.04" it should be possible to run tomcat as normal user and still access lower ports since Lucid.

I am going to try it with authbind but installing Alfresco is not at the top of my todo list right now.

Michael Croes said...

Hi Carsten,

Let me know how that turns out. I read that post too, but haven't had any time to put it to a test myself.
Regards,

Michael

Pauli Price said...

I don't know why I didn't include this in my previous comments. This link setup from the post:

# ln -s /usr/share/java/mysql-connector-java.jar /var/lib/tomcat6/shared/

didn't work for me, I had ended up setting up a link to the mysql-connector in the application's lib directory, out of frustration. Of course when I installed a later war file the link was blown away. This is what I found worked on my 9.10 / Tomcat6 install. It's relative to the common loader.

# ln -s /usr/share/java/mysql-connector-java.jar /usr/share/tomcat6/lib

although, on further consideration, this link relative to the shared loader would probably have worked as well:

# ln -s /usr/share/java/mysql-connector-java.jar /var/lib/tomcat6/shared/lib

/etc/tomcat6/catalina.properties contains the shared and common loader paths, as follows. (NB: As previously noted, the shared loader is blank in a new Tomcat6 install. The value below needs to be in place for the alfresco custom properties to be read)

common.loader=${catalina.home}/lib,${catalina.home}/lib/*.jar

shared.loader=${catalina.base}/shared/classes,${catalina.base}/shared/lib/*.jar

Michael Croes said...

Hi MarFarMa,

The issue is that your shared.loader path is 'wrong'. This guide is for Ubuntu 10.04, where the shared.loader path defaults to shared.loader=${catalina.base}/shared/classes,${catalina.base}/shared/*.jar. You illustrated the effect of changing this path in your comment (or what the result would be if the shared.loader path is set to something else), however I'm assuming the default where there is no 'lib' after shared.

Thanks for sharing this information though, perhaps someone will run into the same issue as you and find the comment.
Regards,

Michael

Anonymous said...

Hello, has anyone tried to Add network place from Windows 7 to alfresco? When I put in the address http://myserver:7070/alfresco it does not work. It works fine from WinXP. Im using alfresco 3.3g.

Unknown said...

Thanks Mike and MarFarMa,

Just want to add that authbind does not work for me, at least in my attempts to bind IMAP to port 143. Even though setting authbind=yes in /etc/defaults/tomcat7 did create the /etc/authbind/byuid/107 file correctly. Using higher unprivileged ports works fine.

Interestingly, creating /etc/authbind/byport/143 and setting ownership to tomcat6 also fails.

Anyone had any luck using privileged ports on Lucid with Alfresco? Or are we stuck with iptables redirects?

Unknown said...

Solved authbind issue:

Failure to bind is not logged in alfresco.log, but /var/log/tomcat6/catalina.out and error is:
[quote]Exception in thread "Thread-29" java.lang.RuntimeException: java.net.SocketException: No such file or directory
at com.icegreen.greenmail.imap.ImapServer.run(ImapServer.java:53)
Caused by: java.net.SocketException: No such file or directory
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:336)
at java.net.ServerSocket.bind(ServerSocket.java:336)
at java.net.ServerSocket.(ServerSocket.java:202)
at com.icegreen.greenmail.AbstractServer.openServerSocket(AbstractServer.java:48)
at com.icegreen.greenmail.imap.ImapServer.run(ImapServer.java:51)
[/quote]

By Default, the file /etc/authbind/byuid/107 contained:

0.0.0.0/32:1,1023

The fix is changing this to:

X.X.X.X/32:1,1023

where x.x.x.x is your local IP address which resolves to your systems hostname.

Anonymous said...

Hi I'm new to alfresco and tried the instructions on your blog. everything went smoothly and I had no problems in installing. Once I restarted the tomcat I tried to open alfresco in browser but it did nothing. I'm using VMware image of Ubuntu 10.04.

can you please tell me how will it work there?

Michael Croes said...

Hi aaekas,

It works exactly the same way. Just make sure the amp is there, then do the apply_amps thing and because the .war in the tomcat webapps is a symlink tomcat should pick up the changes and extract the new war with the amp included.

Hop this is clear enough!
Regards,

Michael

Unknown said...

Dude your rock!!! This worked awesomely!!!

Michael Croes said...

@Shmee Thanks a lot, glad it worked!