CentOS 6.3 minimal install problems

Problem: Booted and only lo interface was enabled.

Solution: Edit the /etc/sysconfig/network-scripts/ifcfg-eth0 and change the following line:




and reboot. Probably a network restart would suffice.

Problem: Root exception is java.lang.ClassNotFoundException: org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory in Tomcat 6

Solution: tomcat-dbcp.jar is not included on the tomcat6 package on yum. Download it from here or copy it from another Tomcat 6 install (copy it to /usr/share/tomcat6/lib).

Problem: Commands not present in /usr/bin or /usr/sbin don’t seem to work, even when you have changed to the command’s directory


I don’t know if it happens with all commands, but happened to the “keytool” utility within the Oracle JDK directory. At the prompt I would type:

$ keytool

And it would not work, I double checked that I has cd’ed to the directory where keytool was (an ls -l would show it). Then, I remembered that I used to have to type it like this on some Linux installs:

$ ./keytool

And it worked!!

Share Button

MySQL Server on Ubuntu 12.04

Install mysql-server via apt-get:

$ sudo apt-get install mysql-server

Set the root password

Activate MySQL:

$ sudo mysql_install_db

Finish the setup by running:

$ sudo /usr/bin/mysql_secure_installation

If you have setup the root password on the first step, confirm it and answer “No” to the change root password question, and accept the default answer for the rest (just press Enter).

To access the mysql console:

$ mysql -u root -p

Here you can issue any other command you want to…

That’s it!

Share Button

Change charset encoding on MySQL databases

It’s pretty simple, just issue an ALTER DATABASE command:

ALTER DATABASE database_name CHARACTER SET charset

To check if it was changed:

SELECT default_character_set_name FROM information_schema.SCHEMATA
WHERE schema_name = "database_name";


Share Button

Apache2 a2enmod rewrite on Ubuntu 12.04 and .htaccess for WordPress Permalinks

When I was setting WordPress up in order to make this blog work, I was changing the Settings>Permalinks section to make the post url look pretty. So I changed the “Common Settings” to “Day and Name” and saved.

When you do that WordPress writes the .htaccess file on the /var/www directory.

Ok, enough introductory small talk! What happens is that the above feature requires that the mod_rewrite (or simply rewrite) module is installed and enabled. Fortunately, it comes pre-installed on Ubuntu 12.04.1, and you just need to issue the

$ sudo a2enmod rewrite

command and that should work, right?

Well, not really… Even though the issued command creates the symlink for the rewrite.load file at /etc/apache2/mods-enabled, you still have to manually edit your /etc/apache2/sites-enabled/000-default file and change the AllowOverride directive from None to All at the /var/www Directory section.

So the section that looks like:

<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None # change this line
    Order allow,deny
    allow from all

Should look like:

<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All # now it will read .htaccess
    Order allow,deny
    allow from all

Restart apache and everything should work. By changing the AllowOverride directive to All you’re telling Apache to read and load the configuration found at the .htaccess file on that Directory. If it is set to None, the .htaccess file is ignored.

More info at:


Share Button

Tomcat 6 on Ubuntu 12.04

Supposing you don’t want to install the Tomcat version that is packaged on Ubuntu (if you need a differente version), this is what you should do:

Download Tomcat here to your home dir.

Add the Tomcat user and group

$ sudo groupadd tomcat
$ sudo useradd -g tomcat -s /usr/sbin/nologin -M tomcat

Go to /usr/local dir and unzip (beware of the file name, you may have downloaded a different/newer version), give appropriate permissions and create a simlink to ‘tomcat’

$ cd /usr/local
$ sudo tar -zxvf ~/apache-tomcat-6.0.36.tar.gz
$ sudo chown -R tomcat. /usr/local/apache-tomcat-6.0.36
$ sudo ln -s apache-tomcat-6.0.36 tomcat

Check if you can start it:

$ sudo /usr/local/tomcat/bin/startup.sh

There should be something like this on the screen:

Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar

Open the following addres on your web browser: http://localhost:8080 (or replace localhost with your server name/ip address) and verify that Tomcat started properly (a pretty page should be displayed telling you that you’ve installed Tomcat succesfully, or something like that).

Now shut it down:

$ sudo /usr/local/tomcat/bin/shutdown.sh

The same messages that appeared when you started it up should appear again (I know, I know, pretty weird).

Now you can use the following script to start and stop Tomcat. Download it to your home directory and place it at /etc/init.d

$ sudo mv tomcat /etc/init.d

To start/stop as the tomcat user, run the following command (it’s already on the script):

$ sudo su -s /bin/bash tomcat -c /usr/local/tomcat/bin/startup.sh
Share Button