Installing Apache and Tomcat and Mysql on Windows 7 PDF Print E-mail
Written by Administrator   
Sunday, 05 December 2010 15:26
Article Index
Installing Apache and Tomcat and Mysql on Windows 7
Installing Apache on WIndows
Tomcat Windows Install
Install mod_jk on Windows
Setting Up Tomcat Manager
Deploying a GWT app on your Tomcat Server
Installing Mysql on Window 7
Installing JDBC
JDBCHello JDBC Test Project for Eclipse
All Pages

Installing Apache and Tomcat and Mysql on Windows 7

Introduction

 I have installed these three things on both PlugBox Linux and Windows 7.  I would say that both are difficult.    It was not surprising that it should be hard on an ARM CPU running Linux.   It was very surprising to me how difficult it was to get working on Windows.

 This is really just the notes I made to myself as I struggled to get this working.   I apologize for the mess.  If it gets read I will clean it up a little.

 


 Apache 2.2.17 Windows Install

Before you start, you should figure out yor computer's IP address.   If you it to be always the same, you may have to configure your wireless router to always give your computer the same IP address when it boots up.  

To find your computer's IP address on your local network,  open a command line box and type

 

ipconfig

Look for the line which says "IPv4 Address....." 

It will frequently be a number like 192.168.1.9   or something similar.

 


http://httpd.apache.org/download.cgi#apache22

Apache download site.
download 2.2.17 non ssl version

Installing was trivial.

I specified 192.168.1.11 when it asked me for the the server address.   However, after installation I could see the icon in the system tray, and opening Firefox to 127.0.0.1 appeared to work fine.
 

 

Tomcat Windows Install


Downloaded .zip file 64bit from

http://tomcat.apache.org/download-60.cgi

unzipped it in a downloads folder.

This page discusses how to install tomcat as a service

http://tomcat.apache.org/tomcat-6.0-doc/windows-service-howto.html

It says I have to start a cmd.exe window and run it as administrator.

I copied the tomcat-6.0.blah.blah file to c:\tomcat
Then I right-clicked on a cmd.exe file and selected run-as-administrator

Then I navigated to c:\tomcat
it says to:

C:\> service.bat install

um ok, but you have to be in c:\tomcat\bin first for it to run the batch. So you really need to change directory to your tomcat\bin folder before trying to run this batch.   Anyway it says:

using CATALINA_HOME: “C:\tomcat”
using CATALINA_BASE: “C:\tomcat”
using JAVA_HOME:    “C:\Program files\Java\jdk1.6.0_18”
using JVM:          “C:\program files\Java\jdk1.6.0_18\jre\bin\server\jvm.dll”


But it apparently isn’t running yet.    I went to control panel, computer management, services and applications, services, and found Apache Tomcat on the list.   It was set to ‘manual’.   

I right-clicked on it, and changed it to ‘automatic.’

It didn’t start right away, so went back into the properties and told it to start.

Yay, I got the Tomcat page!



Installing the Tomcat - Apache Connector mod_jk


Do I need mod-jk?

I was looking through the follow tutorial:  http://www.johnturner.com/howto/winxp-howto.html
Apparently I need to download and install something called mod-jk

The official instructions are here:
http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html

These instructions were a bit vague: saying things like
The simplest way to configure Apache to use mod_jk is to turn on the Apache auto-configure setting in Tomcat and put the following include directive at the end of your Apache httpd.conf file

uhh... guys?  How do you ‘turn on the Apache auto-configure?’

This place seemed to have better info:
http://www.jajakarta.org/tomcat/tomcat3.2-4.0/tomcat-3.2.3/doc/mod_jk-howto.html#s7

To configure Tomcat to generate the Apache auto-configuration add the following block to your TOMCAT_HOME/conf/server.xml file after <AutoWebApp ... />.
<ApacheConfig />

This is crap.   There is no instance of the string ‘AutoWebApp’ in server.xml .  I need a better tutorial:

http://www.anchor.com.au/hosting/dedicated/tomcat_with_apache_on_windows_x64



So I downloaded
mod_jk-1.2.31-httpd-2.2.3.so
From a mirror.   Although they have win64 directories in the mirrors,  they do not have this for Apache, since I guess we are running a 32bit version of apache I guess.

I renamed the file mod_jk.so and placed in the d:\apache\modules folder.


Just below the line:
<Server port="8005" shutdown="SHUTDOWN" debug="0">
Add the following:
<Listener className="org.apache.jk.config.ApacheConfig" modJk="c:/apache/httpd/modules/mod_jk.so"
workersConfig="c:/apache/tomcat/conf/jk/workers.properties" />
And just below the line:
<Host name="localhost" appBase="webapps" unpackWARs="true"
autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
Add the following line:
<Listener className="org.apache.jk.config.ApacheConfig" append="true"
forwardAll="false" modJk="c:/apache/httpd/modules/mod_jk.so" />

Save the changes made to server.xml and restart the Tomcat service.
  • Wait a few seconds, and then check to see if there is a file called mod_jk.conf in tomcat/conf/auto directory.
  • If there is not, you did something wrong!


ok so I went in Computer Management from the control panel and restarted the Apache Tomcat service.

Haha!  It was there!!!!!   Wahoo!
Create the workers.properties file in tomcat/conf/jk, with the following lines to it:
  • # BEGIN workers.properties
    # Definition for Ajp13 worker
    worker.list=ajp13
    worker.ajp13.port=8009
    worker.ajp13.host=localhost
    worker.ajp13.type=ajp13
    # END workers.properties



Setting up Tomcat Manager so it Actually Works

 Tomcat  Manager is a great program- it will automatically deploy your GWT apps with ease and no hassle.   You can start/stop and undeploy your apps easily too!  It is well worth the effort to make them work.
 
Now I just have to set up those pesky config files.
So I went to my tomcat/conf folder and edited tomcat-users.xml
Near the end, but before the </tomcat-users> line I added:

LoadModule jk_module modules/mod_jk.so

<role rolename=”manager”/>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="tomcatuser" password="mygirlfriendsname" roles="manager,manager-gui,manager-script"/>
 
I am not sure if I restarted Tomcat using the control panel/services panel at this point, or not.   No harm in doing so though.
 
After this, I can actually use Tomcat Manager!
 
I did the following, although I'm not sure I had to do it. It didn't seem to hurt anything.
 
To get java programs running on the server with Tomcat to talk to mysql, apparently there need to be some permissions given.   I’m adding the following to my
/usr/local/tomcat/conf/catalina.policy

file.


// 2010_dec_1 kds - adding permissions to mysql and web apps
grant codeBase "file:$(catalina.home)/webapps/-" {
   permission java.net.SocketPermission "192.168.1.11:3306", "connect";
};

grant codeBase "file:$(catalina.home)/webapps/-" {
   permission java.security.AllPermission;
};
 
 

Saving a WAR file from a GWT App and Deploying it On Your Server.

 
I created a GWT application called IORTest.   It ran with the Google debug server just fine.
 
Now I want to deploy it on my Tomcat/Apache server.
 
So I started a cmd.exe prompt box.
 
Then I changed directory to the IORTest project in the workspace
 
cd \eclipse_workspace
cd IORTest
cd war
 
Then I used the jar utility to create the war file:
 
jar cf /tmp/java/IORTest.war *
 
Then used a web browser to open the Tomcat Manager:
 
http://127.0.0.1:8080
Then I clicked on the 'manager' link in the upper left corner of the page.
Then I clicked on the  'Choose File' button in the WAR file to deploy section of the manager page.
I navigated to my war file in d:\tmp\java\IORTest.war and pressed the open button.
 
Back on the tomcat manager page, I pressed the 'Deploy' button.
 
Then I visited the link:
http://127.0.0.1:8080/IORTest
 
and my GWT app came up and ran perfectly!
 
 

Installing Mysql on WIn7


I’ve downloaded mysql-5.1.53-winx64.msi

I ran the installer.   It seemed to go fine, and I let it install to c:\program files\mysql blah blah.

At the end it asked me if I wanted to configure it now with a check box.  I left it checked and then pressed ‘finish’, and I expected a Windows GUI program to startup with options, but it just seemed to go away.  Then I noticed it on the task bar, so the window just got placed below other windows I had open.

Wizard Choice #1
I have three choices:
developer machine - use least memory
server machine - use medium memory
dedicated mysql server - use all memory

I chose Developer Machine.

Wizard Choice #2
Three more choices
Multifunctional Database
Transactional database only
non-transactional only

I chose Multi-functional database.   Really I don’t need transactional wonderfulness.  That has to do with creating databases that you can rollback changes without screwing up multiple processes that are trying to read the data at the same time.

Wizard Choice #3
Next I got to choose where the database storage is.  I didn’t want it on C:, since that only has 30gb left.  So I put it on D:\MySql Datafiles\

Wizard Choice #4
I chose Decision Support DSS/OLAP.    That just means allow up to 20 simultaneous connections.   I probably will never have more than two or three.

Wizard Choice #5
I chose to enable TCP/IP networking.  The standard port number 3306 was fine, and I checked the box to allow a firewall exception for the port.

I also left the Enable Strict Mode checked.   This is very silly sounding.  They don’t indicate why you’d ever want to uncheck it.

Wizard Choice #6  
Standard Character set is fine with me.

Wizard Choice #7
Install as a Windows Service is cool with me.   I also left the checkbox for launching automatically checked.   Then I also checked the box to add the bin folder to the WIndows path because I probably will be using the command line tools.

Wizard Choice #8
 I changed the root password to the same as what I used on the Tonido Plug mysql root account.   I left enable root access from remote machines unchecked.   I also left the anonymous account checkbox unchecked.

Pressed Execute Button

It went away for a while....

Then I could click on Finish

I tried the command line MYSQL console.  It appeared to be working fine.   I logged in as root using the password and dropped the database called ‘test’.



Installing JDBC

So jdbc is in java.sql.* which comes with your jdk.   However, I seem to remember having to put a mysql connector or something in the Java classpath for the Tonido Plug, and I’ll bet I should do the same thing here on Windows.   Here’s what Oracle’s site says about it:

To use the JDBC API with a particular database management system, you need a JDBC technology-based driver to mediate between JDBC technology and the database. Depending on various factors, a driver might be written purely in the Java programming language or in a mixture of the Java programming language and Java Native Interface (JNI) native methods. The JDBC web site maintains a list ofvendors with drivers currently available or under development.

So I googled for ‘mysql jdbc connector’ and landed on the this page, which looks like I can just download a .zip file.

So after unzipping the file, I navigated in one level deep and found the following jar file:

mysql-connector-java-5.1.13-bin.jar

This puppy needs to be in the java CLASSPATH, which is always a nightmare, so I will try to avoid that by simply copying the file to

“C:\program files\Java\jdk1.6.0_18\jre\lib\ext”

Hopefully now all Java programs will be able to find it.
 
No luck so far.  The only way I have been able to run my java program from the command line and have it find the mysql connector is to put the  mysql-connector-java-5.1.13-bin.jar file in the same folder as my class file, and then run with
 
java -cp . JDBCTest
 
I don't understand why setting the CLASSPATH enviornment variable does not work, or even putting in the java/lib/ext folder doesn't work.
 

JDBCHello Eclipse Project

  I wrote a small test program which uses JDBC to communicate with a MySQL server.  It creates a database and a small sample table.  It is released as open source under the MIT license.
 
  Please read the readme.txt file.    You can download it from the following link:
 
 
 
 
 
 
 

Last Updated on Sunday, 05 December 2010 18:27
 

Sponsored Links

Bold Inventions, Powered by Joomla!; Joomla templates by SG web hosting