Download - How to Install Php on Tomcat
-
8/10/2019 How to Install Php on Tomcat
1/21
joseluisbz's BlogEste Blog trata de aspectos del rea del Software, Sistemas, Hardware o Electrnica
Saltar al contenido.
Inicio
About Obtaining Size or Dimension of Images
Manually Installing Php, Tomcat and ttpd !ounge "
Manually Installing PHP with Tomcat only
Publicado en#$%&'%$'#(de)oseluisbz
2 Votes
Maybe this post is rare for someone, but I will try to explain how to
install PHPworking with Tomcat.
This tutorial was tested using indows ! of "2 bits.
#$# can works with the library named #%&', the last library that help us to
reach the goal is the (ersion ).2.).
The #%&' ).2.) library contains .dlland .jarfiles that allow us to configure
some *not all+ #$# (ersion with Tomcat.
ll instalation will be made in the folder-
C:\ServerWeb\
PHP
http://joseluisbz.wordpress.com/http://joseluisbz.wordpress.com/2013/10/26/manually-installing-php-with-tomcat-only/#contenthttp://joseluisbz.wordpress.com/http://joseluisbz.wordpress.com/about/http://joseluisbz.wordpress.com/2013/08/06/obtaining-size-or-dimension-of-images/http://joseluisbz.wordpress.com/2014/01/17/manually-installing-php-tomcat-and-httpd-lounge/http://joseluisbz.wordpress.com/2013/10/26/manually-installing-php-with-tomcat-only/http://joseluisbz.wordpress.com/2013/10/26/manually-installing-php-with-tomcat-only/http://joseluisbz.wordpress.com/author/joseluisbz/http://joseluisbz.wordpress.com/http://joseluisbz.wordpress.com/http://joseluisbz.wordpress.com/2013/10/26/manually-installing-php-with-tomcat-only/#contenthttp://joseluisbz.wordpress.com/http://joseluisbz.wordpress.com/about/http://joseluisbz.wordpress.com/2013/08/06/obtaining-size-or-dimension-of-images/http://joseluisbz.wordpress.com/2014/01/17/manually-installing-php-tomcat-and-httpd-lounge/http://joseluisbz.wordpress.com/2013/10/26/manually-installing-php-with-tomcat-only/http://joseluisbz.wordpress.com/2013/10/26/manually-installing-php-with-tomcat-only/http://joseluisbz.wordpress.com/author/joseluisbz/ -
8/10/2019 How to Install Php on Tomcat
2/21
The last (ersion of #$# that works with that #%&' (ersion was the ).2./. Then
I will use the#$# ).2./ for in"2.
The contents of the .0ip file was uncompressed in the folder-
C:\ServerWeb\Php_5.2.16\
Inside of this folder there are two files containing templates of configuration of
php-
php.ini-dist*for de(eloping+ and php.ini-recommended*for production+,
the difference consist into if the errors will be shown, while the (ersion for
de(eloping shows the errors and other information, the (ersion for production
does not.
s I1m testing I took php.inidist and copied-copy php.ini-dist php.ini
Now lets go to declare to system the path of the PHP.
http://windows.php.net/downloads/releases/archives/php-5.2.16-Win32-VC6-x86.ziphttp://windows.php.net/downloads/releases/archives/php-5.2.16-Win32-VC6-x86.ziphttp://joseluisbz.files.wordpress.com/2013/10/coying-php-ini.pnghttp://windows.php.net/downloads/releases/archives/php-5.2.16-Win32-VC6-x86.zip -
8/10/2019 How to Install Php on Tomcat
3/21
-
8/10/2019 How to Install Php on Tomcat
4/21
'ater, the System Propertiesdialog box is shown.
http://joseluisbz.files.wordpress.com/2013/10/systemproperties2.png -
8/10/2019 How to Install Php on Tomcat
5/21
3ow, e selectAdvancedtab and press the Environment
Variablesbutton.
http://joseluisbz.files.wordpress.com/2013/10/systemproperties3.png -
8/10/2019 How to Install Php on Tomcat
6/21
$ere we select the PATH(ariable and press the Editbutton.
4inally modify the (ariable (alue adding at the end the path of PHPand press
the !button.
Tomcat
The (ersion of Tomcattested that worked well was the !.5.6, because !.5.62
(ersion had problems with starting and stopping in indows. Then this post
will work with Tomcat !.5.6 for in"2.
The contents of the .0ip file was uncompressed in the folder-
C:\ServerWeb\Tomcat_7.0.41\
"ndicating to Tomcat the path of #ava$ %sing Environment Variables
http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.41/bin/apache-tomcat-7.0.41-windows-x86.ziphttp://joseluisbz.files.wordpress.com/2013/10/systemproperties_editingpath.pnghttp://joseluisbz.files.wordpress.com/2013/10/systemproperties4b.pnghttp://archive.apache.org/dist/tomcat/tomcat-7/v7.0.41/bin/apache-tomcat-7.0.41-windows-x86.zip -
8/10/2019 How to Install Php on Tomcat
7/21
In order to do this, we need to create a new (ariable with name #AVA&H'E,
this (ariable is checked by Tomcat.
Similarly to declare to path of #$#, but we need to access to Environment
Variables, pressing the Newbutton.
In the New System Variabledialog box, we write the name of the (ariable
with#AVA&H'Eand the (ariable (alue with the path of 7a(a, in my case
()*Program +iles*#ava*,d./.0&12*
http://joseluisbz.files.wordpress.com/2013/10/systemproperties_adding_newvariable.pnghttp://joseluisbz.files.wordpress.com/2013/10/systemproperties5b.png -
8/10/2019 How to Install Php on Tomcat
8/21
s you can see the new (ariable was added.
3ow we will make some changes optional on some files in the subdirectory
namedbininside the folder of Tomcat.To start Tomcat silently *without console window popup+, change in the file
namedsetclasspath.bat, the line set &34N#AVA
set _RUNJAVA="%JRE_HOME%\bin\javaw"
http://joseluisbz.files.wordpress.com/2013/10/systemproperties6b.png -
8/10/2019 How to Install Php on Tomcat
9/21
3ow, lets go to mak changes in the file service.batin the subdirectory
namedbin.
To change the ser(ice name and name to be displayed *this not alters of
functionality of Tomcat1s ser(ice+, we make this-
set SERVICE_NAME=Tomcat7.0.41
set PR_DISPLAYNAME=Tomcat7.0.41
'ater let1s go to modify the description of this ser(ice-
http://joseluisbz.files.wordpress.com/2013/10/editing_service_bat.pnghttp://joseluisbz.files.wordpress.com/2013/10/editing_setclasspath_bat.png -
8/10/2019 How to Install Php on Tomcat
10/21
set PR_DESCRIPTION=Tomcat 7.0.41 Server
To start Tomcat when indows does, we make the following change-
"%EXECUTABLE%" //IS//%SERVICE_NAME% --Startup auto
e can modify our web ser(er port, which is initially set to 5050, change it
to 50, in this case we need to make changes in the file server.6mlin the
http://joseluisbz.files.wordpress.com/2013/10/editing_service_bat3.pnghttp://joseluisbz.files.wordpress.com/2013/10/editing_service_bat21.png -
8/10/2019 How to Install Php on Tomcat
11/21
subdirectory named confinside the folder of Tomcat.
8ou can also set the directory where all web applications will be deployed, for
this demostration, I made a new folder named7ebappslocated inside
of Server7eb.
C:\ServerWeb\Webapps\
Inside of this folder, I made other folder named http, specifically a context that
represents an application.
C:\ServerWeb\Webapps\http\
These changes in the file server.6mlwill be-
http://joseluisbz.files.wordpress.com/2013/10/editing-server_xml1.png -
8/10/2019 How to Install Php on Tomcat
12/21
-
8/10/2019 How to Install Php on Tomcat
13/21
-
8/10/2019 How to Install Php on Tomcat
14/21
nd remo(e-
service.bat remove
Integrating Tomcat with PHP
This changes are in order to use #$# with Tomcat.
9ownload the #$# %xtension &ommunity 'ibrary (ersion ).2.) for in"2.
4or this example, I will unpack the contents to *although this is not necessary+-
C:\ServerWeb\Pecl_5.2.5\
http://museum.php.net/php5/pecl-5.2.5-Win32.ziphttp://joseluisbz.files.wordpress.com/2013/10/removing-service_bat.pnghttp://joseluisbz.files.wordpress.com/2013/10/stoping-service_bat.pnghttp://museum.php.net/php5/pecl-5.2.5-Win32.zip -
8/10/2019 How to Install Php on Tomcat
15/21
&opy the file php2servlet.dllfrom the pecl-2.8.2-7in98.:ipto the
folder()*Server7eb*Php&2.8.;*
&opy the file php&,ava.dllfrom the pecl-2.8.2-7in98.:ipto the
folder()*Server7eb*Php&2.8.;*e6t*
In order to make use of php&,ava.dllwe need to make changes in the
configuration file of #$#, php.ini, adding a new line like is shown below.
extension=php_java.dll
So far e(erything is ready as far as #$# is concerned.
&opy the file php&,ava.,arfrom the pecl-2.8.2-7in98.:ipto the
folder()*Server7eb*Tomcat&/.0.1*lib*
3ow, we need to make changes in the file named phpsrvlt.,arand create a new
file named php2srvlt.,ar
4irst, we need to uncompress the file with *in my case+-
"C:\Program Files\Java\jdk1.7.0_45\bin\jar.exe" xfv phpsrvlt.jar
http://joseluisbz.files.wordpress.com/2013/10/editing_php_ini.png -
8/10/2019 How to Install Php on Tomcat
16/21
Second, as can be seen, two folders are decompressed one call net, inside which
there is another folder named php. In this folder php there are multifle files,
including one calledreflect.propertiesand another
called servlet.properties. The contents of both files must be-
library=php5servlet
http://joseluisbz.files.wordpress.com/2013/10/extracting-file-from-phpsrvlt_jar1.png -
8/10/2019 How to Install Php on Tomcat
17/21
s you can see, without spaces.
Third, let1s go to create the needed file-
"C:\Program Files\Java\jdk1.7.0_45\bin\jar.exe" cvf php5srvlt.jar net/php/
http://joseluisbz.files.wordpress.com/2013/10/editing-servlet_propertiesb.pnghttp://joseluisbz.files.wordpress.com/2013/10/editing-reflect_properties_b.png -
8/10/2019 How to Install Php on Tomcat
18/21
4ourth, include the php2srvlt.,arfile to be used by applications in Tomcat,
copying this file into subdirectory libof Tomcat
9irectory ()*Server7eb*Tomcat&/.0.1*lib*in this case will be a(ailable
for all applications of Tomcat.
3ow, e need to modify the fileweb.6ml*9eployment 9escriptor+ in the
subdirectory named confinside of Tomcat installation folder.
4irst change- declaring the name of ser(let and its classes.
php
net.php.servlet
php-formatter
net.php.formatter
http://joseluisbz.files.wordpress.com/2013/10/adding-file-to-php5srvlt_jar.png -
8/10/2019 How to Install Php on Tomcat
19/21
Second change- including the mapping of the ser(lets and classes declared
before.
php
*.php
php-formatter
*.phps
http://joseluisbz.files.wordpress.com/2013/10/editing-web_xml1.png -
8/10/2019 How to Install Php on Tomcat
20/21
Third change- including and establishing the files and its order in which the
default ser(let looks for the :welcome file:.
index.php
'ast we will test the integration, creating a file named test.php inside of
()*Server7eb*7ebapps*http*, the content is-
http://joseluisbz.files.wordpress.com/2013/10/editing-web_xml3.pnghttp://joseluisbz.files.wordpress.com/2013/10/editing-web_xml2.png -
8/10/2019 How to Install Php on Tomcat
21/21
http://joseluisbz.files.wordpress.com/2013/10/testing-test_php.pnghttp://joseluisbz.files.wordpress.com/2013/10/creating-test_php.png