Seja bem-vindo

Espero que as dicas apresentadas aqui sejam úteis para você.
Se gostar de alguma coisa, não esqueça de comentar e recomendar, caso ache importante.

Currículo

quinta-feira, 18 de setembro de 2014

A best approach to install Liferay on Tomcat using Ubuntu's provided package

When you install Tomcat using apt-get on Ubuntu, its root folder will be in /var/lib/tomcat7

Inside of it, there will be some folders and symbolic links

work -> ../../cache/tomcat7
logs -> ../../log/tomcat7
conf -> /etc/tomcat7
shared
server
common
temp
webapps

Folders bin and lib will be in /usr/share/tomcat7

Following the install process described in Installing Liferay on Tomcat 7 you will see, in the first sentence:

Liferay Home is one folder above Tomcat’s install location.
If you start Liferay without changing anything, just like the tutorial says, Liferay will create its folders in the Liferay Home, which is, by default, /var/lib/.

Having application data folders inside /var/lib is not a good idea, just like Dave Kliczbor commented on the comments section on that page.

In order to "fix" that behaviour, create the file /var/lib/tomcat7/webapps/ROOT/WEB-INF/classes/portal-ext.properties and add the line

liferay.home=/var/lib/tomcat7
Create the folders /var/lib/tomcat7/data and /var/lib/tomcat7/deploy and make them writeable for the user tomcat7 running

sudo chown -R tomcat7:tomcat7 /var/lib/tomcat7/data
sudo chown -R tomcat7:tomcat7 /var/lib/tomcat7/deploy


That's enough to have your Liferay server ready to run.

sexta-feira, 29 de agosto de 2014

How to fix "Setting locale failed" message on Ubuntu

Sometimes, when you try perform some activities on Ubuntu like manage packages using apt-get, you can see messages like:
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "en_US:en",
LC_ALL = (unset),
LC_TIME = "pt_BR.UTF-8",
LC_MONETARY = "pt_BR.UTF-8",
LC_ADDRESS = "pt_BR.UTF-8",
LC_TELEPHONE = "pt_BR.UTF-8",
LC_NAME = "pt_BR.UTF-8",
LC_MEASUREMENT = "pt_BR.UTF-8",
LC_IDENTIFICATION = "pt_BR.UTF-8",
LC_NUMERIC = "pt_BR.UTF-8",
LC_PAPER = "pt_BR.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

and
locale: Cannot set LC_ALL to default locale: No such file or directory

You can see what the problem is by typing:
locale

You will see something like:
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=pt_BR.UTF-8
LC_TIME=pt_BR.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=pt_BR.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=pt_BR.UTF-8
LC_NAME=pt_BR.UTF-8
LC_ADDRESS=pt_BR.UTF-8
LC_TELEPHONE=pt_BR.UTF-8
LC_MEASUREMENT=pt_BR.UTF-8
LC_IDENTIFICATION=pt_BR.UTF-8
LC_ALL=

As you can see, LC_ALL has no value.

Type:
sudo update-locale LC_ALL="en_US.UTF-8"

This adds LC_ALL=en_US.UTF-8 to /etc/default/locale.

Reboot your server and check again by typing:
locale
If you get something like the output bellow, then you are ok:
LANG=en_US.UTF-8LANGUAGE=en_US:enLC_CTYPE="en_US.UTF-8"LC_NUMERIC="en_US.UTF-8"LC_TIME="en_US.UTF-8"LC_COLLATE="en_US.UTF-8"LC_MONETARY="en_US.UTF-8"LC_MESSAGES="en_US.UTF-8"LC_PAPER="en_US.UTF-8"LC_NAME="en_US.UTF-8"LC_ADDRESS="en_US.UTF-8"LC_TELEPHONE="en_US.UTF-8"LC_MEASUREMENT="en_US.UTF-8"LC_IDENTIFICATION="en_US.UTF-8"LC_ALL=en_US.UTF-8
See ya.

How to install Oracle Java on Ubuntu 14.04

Ubuntu usually comes with OpenJDK, but if you need, or simply prefer to use Oracle's Java proprietary package, then you can follow the steps bellow and have it installed on Ubuntu.

On terminal, type:

sudo add-apt-repository ppa:webupd8team/java (adds the repository to the sources list)
You will see some info, and you can safely type ENTER to continue.
sudo apt-get update (updates the available packages list)
sudo apt-get install oracle-java7-installer (download and install Oracle Java package)

In order to check if Java was intalled, type:

java -version

If everything is right, you should see something like this:

java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

Even though Oracle Java is installed, it's still not the default Java.

To configure it correctly, you have to type:

sudo update-alternatives --config java

I hope this post can be useful for someone else.

domingo, 1 de junho de 2014

How to install ImageMagick from sources on Ubuntu 14.04

I was running an Alfresco Community 4.2.f instance on Ubuntu 14.04, but thumbnails and avatar were not working.
When the server started, I got the following error message about ImageMagick:

no decode delegate for this image format

The solution I've found was to remove the ImageMagick installed using apt-get, which at the time of writing was, 6.7.7.10, and install the latest version available at the ImageMagick site from source.

Below are the steps I've followed:

Removing ImageMagick package:
$ sudo apt-get remove imagemagick

Installing the build dependencies:
$ sudo apt-get update
$ sudo apt-get install build-essential checkinstall libx11-dev libxext-dev zlib1g-dev libpng12-dev libjpeg-dev libfreetype6-dev libxml2-dev
$ sudo apt-get build-dep imagemagick

Downloading ImageMagick sources:
$ wget http://mirrors-au.go-parts.com/mirrors/ImageMagick/ImageMagick-6.8.9-2.tar.gz

Preparing and building:
$ tar -xzvf ImageMagick-6.8.9-2.tar.gz
$ cd ImageMagick-6.8.9-2
$ ./configure
$ sudo checkinstall
$ sudo ldconfig /usr/local/lib 

Following the above steps ImageMagick was installed and ready to use.
By default, it will be installed in /usr/local/bin

In order to allow Alfresco to generate thumbnails, it's required to setup the
alfresco-global.properties

Configure properties bellow and it's done:
img.exe=convert
img.root=/usr/local/bin

References:
http://namhuy.net/1730/install-imagemagick-6-8-linux-mint-ubuntu.html
http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=17059#p63413

domingo, 18 de maio de 2014

Some useful tips using the find linux command to search for text

Searching for texts into projects' source code is a common task when you are developing.

I think the best aproach is to go to shell and run the commands bellow:

Search for xml files containing the text "org.alfresco.util.CronTriggerBean"
find . -type f -name "*.xml" -print | xargs grep "org.alfresco.util.CronTriggerBean"


Look for javascript files containing the text "renderPickerHTML"
find . -type f -name "*" -print | xargs grep "renderPickerHTML"

But there are some projects that have lots of "minimized" files, and those files are not that useful when you are searching for sample code. In these cases, it's better to filter the results, ignoring the minized ones.

To do this, you just need to include one parameter to your command, like this

find . -type f -not -iwholename '*-min.js' -name "*" -print | xargs grep "renderPickerHTML"

The only difference here is the "-not -iwholename '*-min.js'.


I hope you enjoy this quick tip.