PDA

View Full Version : Install Laszlo in to apache + php + mysql


curate
12-25-2004, 03:41 PM
Hi
I was installing Laszlo 2.2.1 and testing it , its looks super :)

I have other server side applications
run in Apache+php+Mysql (all in Win xp)

I don't want to run two servers like

Apache+php+Mysql
and
Tomcat + Laszlo (different port)

How to install Tomcat + Laszlo in to my current server, all in to one port.

Should be very nice if my server capabilities looks that way:
Apache + php + Mysql + Tomcat + Laszlo

yossie
12-25-2004, 06:59 PM
The typical way to use a servlet container (tomcat or jetty) with a web server (apache) is to use mod_jk to communicate between them. The web server receives all incoming requests and, if they have a specific path pattern (which is degined with a jk_mount option available once you install mod_jk),. they are forwarded through a specific protocol and port to a servlet containter on the same host, or another host. The results come back over the same internal port and are sent out by apache as the result of the request. In effect, the servlet container is transparently accessed by the browser at the same address as the rest of the apache environment (php, etc..) - Yossie

d~l
12-26-2004, 04:03 AM
You can connect your Apache and Tomcat servers using mod_jk (or mod_jk2) connector .. as suggested above .. but you say that you prefer your webapps to be integrated on one server / one port

I documented another approach here .. how to install PHP 5.0.2 on Tomcat (http://www.laszlosystems.com/developers/community/forums/showthread.php?threadid=1321&highlight=phpservlet)

PHPservlet runs PHP in CGI mode .. (map to php-cgi.exe not php.exe) .. running on Tomcat 5 server.

You can simplify the installation I set out in that note and integrate PHPservlet into your LPS-2.2.1 installation. Then access MySQL as usual through PHP on your Tomcat server.

PHP source can be compiled to run on Tomcat but I could not get that to work. Easier to try out PHPservlet.

..

Why bother to install PHP on Tomcat?

.. to allow server side scripting and PHP generation of local resources .. such as SWF to be imported by LZX apps.

ph34rhk
12-27-2004, 04:59 PM
I've read several documents on the mod_jk and can't get it to connect, I'm not sure what I'm doing anymore. I don't mind running two sets of servers, just as long as it works. I don't have to install tomcat since Laszlo includes it, correct? I made a virutal host file in my httpd.conf, how do I make it so that that website is forwarded to port 8080? I really don't want to reinstall anything since everything is sitting comfterbly. Can anyone help me?

yossie
12-27-2004, 09:13 PM
These instructions are for the current stable release of lps - lps-2.2.1.

---

Add the following before in server/conf/server.xml at the obvious place (next to the other connector).

<Connector port="8009"
enableLookups="false" redirectPort="8443" debug="0"
protocol="AJP/1.3" />

Add the following to your apache.conf file:

LoadModule jk_module modules/mod_jk-eapi.so
<IfModule mod_jk.c>
JkWorkersFile conf/workers.properties
JkLogFile logs/jk.log
JkLogLevel error
JkMount /lps-2.2.1 localhost
JkMount /lps-2.2.1/* localhost
</IfModule>

Make sure to find a correct mod_jk for your version of apache (takes a bit of work, but they are out there) and place it in your apache modules directory.

add a file 'workers.properties' in your apache conf directory (this is a long file, much of which is defaults and comments. I can't spare the cycles to trim it up to it's minimal necessaties):

---

# workers.properties -
#
# This file provides jk derived plugins with the needed information to
# connect to the different tomcat workers. Note that the distributed
# version of this file requires modification before it is usable by a
# plugin.
#
# As a general note, the characters $( and ) are used internally to define
# macros. Do not use them in your own configuration!!!
#
# Whenever you see a set of lines such as:
# x=value
# y=$(x)\something
#
# the final value for y will be value\something
#
# Normaly all you will need to do is un-comment and modify the first three
# properties, i.e. workers.tomcat_home, workers.java_home and ps.
# Most of the configuration is derived from these.
#
# When you are done updating workers.tomcat_home, workers.java_home and ps
# you should have 3 workers configured:
#
# - An ajp12 worker that connects to localhost:8007
# - An ajp13 worker that connects to localhost:8009
# - A jni inprocess worker.
# - A load balancer worker
#
# However by default the plugins will only use the ajp12 worker. To have
# the plugins use other workers you should modify the worker.list property.
#
#

# OPTIONS ( very important for jni mode )

#
# workers.tomcat_home should point to the location where you
# installed tomcat. This is where you have your conf, webapps and lib
# directories.
#
workers.tomcat_home=/usr/local/jakarta-tomcat-4.1.12

#
# workers.java_home should point to your Java installation. Normally
# you should have a bin and lib directories beneath it.
#
workers.java_home=/usr/java/j2sdk1.4.0_03

#
# You should configure your environment slash... ps=\ on NT and / on UNIX
# and maybe something different elsewhere.
#
ps=/

#
#------ ADVANCED MODE ------------------------------------------------
#---------------------------------------------------------------------
#

#
#------ DEFAULT worket list ------------------------------------------
#---------------------------------------------------------------------
#
#
# The workers that your plugins should create and work with
#
# Add 'inprocess' if you want JNI connector
worker.list=ajp12, sf
# , inprocess


#
#------ DEFAULT ajp12 WORKER DEFINITION ------------------------------
#---------------------------------------------------------------------
#

#
# Defining a worker named ajp12 and of type ajp12
# Note that the name and the type do not have to match.
#
worker.ajp12.port=8007
worker.ajp12.host=localhost
worker.ajp12.type=ajp12
#
# Specifies the load balance factor when used with
# a load balancing worker.
# Note:
# ----> lbfactor must be > 0
# ----> Low lbfactor means less work done by the worker.
worker.ajp12.lbfactor=1

#
#------ DEFAULT ajp13 WORKER DEFINITION ------------------------------
#---------------------------------------------------------------------
#

#
# Defining a worker named ajp13 and of type ajp13
# Note that the name and the type do not have to match.
#
worker.sf.port=8009
worker.sf.host=localhost
worker.sf.type=ajp13
#
# Specifies the load balance factor when used with
# a load balancing worker.
# Note:
# ----> lbfactor must be > 0
# ----> Low lbfactor means less work done by the worker.
worker.sf.lbfactor=1

#
# Specify the size of the open connection cache.
#worker.ajp13.cachesize

#
#------ DEFAULT LOAD BALANCER WORKER DEFINITION ----------------------
#---------------------------------------------------------------------
#

#
# The loadbalancer (type lb) workers perform wighted round-robin
# load balancing with sticky sessions.
# Note:
# ----> If a worker dies, the load balancer will check its state
# once in a while. Until then all work is redirected to peer
# workers.
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=ajp12, sf


#
#------ DEFAULT JNI WORKER DEFINITION---------------------------------
#---------------------------------------------------------------------
#

#
# Defining a worker named inprocess and of type jni
# Note that the name and the type do not have to match.
#
worker.inprocess.type=jni

#
#------ CLASSPATH DEFINITION -----------------------------------------
#---------------------------------------------------------------------
#

#
# Additional class path components.
#
worker.inprocess.class_path=$(workers.tomcat_home) $(ps)lib$(ps)tomcat.jar

#
# Setting the command line for tomcat.
# Note: The cmd_line string may not contain spaces.
#
worker.inprocess.cmd_line=start

# Not needed, but can be customized.
#worker.inprocess.cmd_line=-config
#worker.inprocess.cmd_line=$(workers.tomcat_home)$ (ps)conf$(ps)server.xml
#worker.inprocess.cmd_line=-home
#worker.inprocess.cmd_line=$(workers.tomcat_home)

#
# The JVM that we are about to use
#
# This is for Java2
#
# Windows
worker.inprocess.jvm_lib=$(workers.java_home)$(ps) jre$(ps)bin$(ps)classic$(ps)jvm.dll
# IBM JDK1.3
#worker.inprocess.jvm_lib=$(workers.java_home)$(ps )jre$(ps)bin$(ps)classic$(ps)libjvm.so
# Unix - Sun VM or blackdown
#worker.inprocess.jvm_lib=$(workers.java_home)$(ps )jre$(ps)lib$(ps)i386$(ps)classic$(ps)libjvm.so

#
# And this is for jdk1.1.X
#
#worker.inprocess.jvm_lib=$(workers.java_home)$(ps )bin$(ps)javai.dll


#
# Setting the place for the stdout and stderr of tomcat
#
worker.inprocess.stdout=$(workers.tomcat_home)$(ps )logs$(ps)inprocess.stdout
worker.inprocess.stderr=$(workers.tomcat_home)$(ps )logs$(ps)inprocess.stderr

#
# Setting the tomcat.home Java property
#
#worker.inprocess.sysprops=tomcat.home=$(workers.t omcat_home)

#
# Java system properties
#
# worker.inprocess.sysprops=java.compiler=NONE
# worker.inprocess.sysprops=myprop=mypropvalue

#
# Additional path components.
#
# worker.inprocess.ld_path=d:$(ps)SQLLIB$(ps)bin
#

---

Once you do these four things. You SHOULD be able to restart apache and tomcat (via the desktop icon, for the latter) and all should work - your webapp will be accessible directly in apache at path /lps-2.2.1

This process is by no means SIMPLE in the classical sense, but it does work by and large.

Good luck! - Yossie

ph34rhk
12-27-2004, 10:52 PM
Thanks. I've searched the forum over and over to find another problem that I now have, the server spits out the code instead of the compiled application. Sorry if I'm blind to all this, its really late and I'm just trying to fix it. Thanks for being patient with me.

d~l
12-28-2004, 07:12 AM
What version of Apache are you running and on what port?

ph34rhk
12-28-2004, 09:34 AM
Apache 2.0.52 on port 80

d~l
12-28-2004, 10:09 AM
If you have Apache 2 .. you should use mod_jk2 .. and not the earlier mod_jk.

The setup is different .. e.g. workers2.properties not workers.properties ..

There are various tutorials around .. and earlier references to mod_jk2 in this forum .. search for mod_jk2.

...

I should add that you can use mod_jk with Apache 2.x ..

See this thread on .. future of mod_jk (http://www.mail-archive.com/tomcat-user@jakarta.apache.org/msg143903.html)