Tuesday, May 15, 2012

Installing Tomcat 7 and Apache2 with mod_jk on Ubuntu 12.04

This is a compact note on how to install Tomcat and Apache2, and then configure to connect the Apache Web Server to Tomcat using mod_jk on Ubuntu 12.04 (the basics are the same, so should work on all OS with minor modifications).

1. Installing Apache, Tomcat

sudo apt-get install apache2

Test the installation from the browser using http://localhost/

sudo apt-get install tomcat7
sudo apt-get install tomcat7-admin

Create a test application for tomcat.
cd /var/lib/tomcat7/webapps
sudo mkdir tomcat-demo
sudo mkdir tomcat-demo/helloworld
sudo vim tomcat-demo/helloworld/index.jsp

and paste the code
<HTML>
 <HEAD>
  <TITLE>Hello World</TITLE>
 </HEAD>
 <BODY>
  <H1>Hello World</H1>
  Today is: <%= new java.util.Date().toString() %>
 </BODY>
</HTML>
Test the installation from the browser using

http://localhost:8080/tomcat-demo/helloworld/

2. Installing and configuring mod_jk

sudo apt-get install libapache2-mod-jk

First lets enable the redirect port 8443 on Tomcat

sudo vim /etc/tomcat7/server.xml

and uncomment the following line
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
Now we will create our workers.properties file for Apache.

sudo vim /etc/apache2/workers.properties

paste the text
# Define 1 real worker using ajp13 
worker.list=worker1 
# Set properties for worker (ajp13) 
worker.worker1.type=ajp13 
worker.worker1.host=localhost
worker.worker1.port=8009
Now to ask Apache to use this worker

sudo vim /etc/apache2/mods-available/jk.conf

change the JkWorkersFile property to
/etc/apache2/workers.properties


Finally to configure the URL Apache should pass through the Tomcat

sudo vim /etc/apache2/sites-enabled/000-default

and add the following line in your configurtation
<VirtualHost *:80>
.......................................
.......................................
JkMount /tomcat-demo* worker1
</VirtualHost *:80>
Now, restart the servers

sudo /etc/init.d/tomcat7 restart
sudo /etc/init.d/apache2 restart

and test with
http://localhost/tomcat-demo/helloworld/
it should work similarly to
http://localhost:8080/tomcat-demo/helloworld/

Thursday, May 10, 2012

Wordpress 3.3.2 Featured Image Missing!!!

Installed my Wordpress 3.3.2 and couldn't find the whole "Featured Image" for a post functionality missing. Googled a lot and here is what I found.

Add to the theme functions.php
add_theme_support('post-thumbnails')
and hey, it is working.