Manually Installing Php, Tomcat and Httpd Lounge


This is my last post about installation of this products (Php, Tomcat and Httpd).
This tutorial was tested using Windows 7 of 32 bits.
The steps that we will describe are:

All instalation will be made in the folder:

C:\ServerWeb\

All commands through CLI (CMD console) were in Administrator mode.
In this post I will work using symbolic links with mklink command, in this manner if I need to change the version of some product, only I will need to redirect its link.


PHP


Preparations for the Php installation.

I will use the Php 5.5.8 for Win32.
The contents of the .zip file was uncompressed in the folder:

C:\ServerWeb\Php_5.5.8\

But with symbolic link all operations of PHP will be done under the folder:

C:\ServerWeb\Php\

To create the symbolic link for PHP, use the command:

mklink /J "C:\ServerWeb\Php" "C:\ServerWeb\Php_5.5.8"

Php_00_mklink for Php

If you want to remove this link, you can use:

rd "C:\ServerWeb\Php"

Php_01_rd for Php


Declaring to system the path of PHP.

Now, Is needed to access to variables system, with this manner or according to your preference:
Php_02_Sysdm.cpl

Later, the System Properties dialog box is shown.
Php_03_SystemProperties

Now, We select Advanced tab and press the Environment Variables button.
Php_04_SystemProperties (Advance)

Here we select the Path variable and press the Edit button.
Php_05_EnvironmentVariables_Edit

Modify the variable value adding at the end the path of PHP and press the OK button.

C:\ServerWeb\Php\

Php_06_EditSystemVariable_Path


Working with the PHP configuration file php.ini.

Inside of this folder there are two files containing templates of Php configuration:
php.ini-development and php.ini-production, the difference consist into if the errors will be shown, while the version for developing shows the errors and other information, the version for production does not.
As I’m testing I took php.ini-development and copied:
Php_07_Coying php.ini

To enable error tracking change the value of the variable error_log.

error_log = "C:\ServerWeb\Php\logs\php-errors.log"

Php_08_Editing_php_ini (error_log)

To limit the size of POST data change the value of the variable post_max_size.

post_max_size = 5M

Php_09_Editing_php_ini (post_max_size)

To indicate the folder of extensions change the variable extension_dir.

extension_dir = "C:\ServerWeb\Php\ext\"

Php_10_Editing_php_ini (extension_dir)

We indicate the maximum file size by changing the variable upload_max_filesize.

upload_max_filesize = 3M

Php_11_Editing_php_ini (upload_max_filesize)

To enable the use of mysqli, uncheck the respective library.

extension=php_mysqli.dll

Php_12_Editing_php_ini (Enabling php_mysqli.dll)


TOMCAT


Java previous changes.

Like other products, if necessary change the version of java, using symbolic link will be easy.

Also create a symbolic link to the directory jdk.

mklink /J "C:\Program Files\Java\jdk\" "C:\Program Files\Java\jdk1.7.0_45\"

Jdk_00_mklink for Jdk

To see as was definitively:

dir "C:\Program Files\Java"

Jdk_02_dir

If you want to remove this link, you can use:

rd "C:\Program Files\Java\jdk\"

Jdk_01_rd for Jdk


Preparations for the Tomcat installation.

Then this post will work with Tomcat 7.0.50 for Win32.
The contents of the .zip file was uncompressed in the folder:

C:\ServerWeb\Tomcat_7.0.50\

But with symbolic link all operations of TOMCAT will be done under the folder:

C:\ServerWeb\Tomcat\

To create the symbolic link for TOMCAT, use the command:

mklink /J "C:\ServerWeb\Tomcat" "C:\ServerWeb\Tomcat_7.0.50"

Tomcat_00_mklink for Tomcat

If you want to remove this link, you can use:

rd "C:\ServerWeb\Tomcat"

Tomcat_01_rd for Tomcat


Declaring to system the path of TOMCAT.

Now, Is needed to access to variables system, with this manner or according to your preference:
Tomcat_02_Sysdm-cpl

Later, the System Properties dialog box is shown.
Tomcat_03_SystemProperties

Now, We select Advanced tab and press the Environment Variables button.
Tomcat_04_SystemProperties (Advance)

Here we press the New button.
Tomcat_05_EnvironmentVariables_New

In the New System Variable dialog box, we write the name of the variable with JAVA_HOME and the variable value with the path of Java, in my case:

C:\Program Files\Java\jdk

Tomcat_06_SystemProperties_Adding_NewVariable

As you can see the new variable was added.
Tomcat_07_EnvironmentVariables_OK


Optional changes to the Tomcat’s configuration.

Now we will make some changes optional on some files in the bin subdirectory inside of Tomcat folder.

To start Tomcat silently (without console window popup), change in the file named setclasspath.bat, the line set _RUNJAVA.

set _RUNJAVA="%JRE_HOME%\bin\javaw"

Tomcat_08_Editing_setclasspath-bat (_RUNJAVA)

Now, lets go to mak changes in the file service.bat in the bin subdirectory.

To change the service name and name to be displayed (this not alters of functionality of Tomcat’s service), we make this:

set SERVICE_NAME=Tomcat7.0.50
set PR_DISPLAYNAME=Tomcat7.0.50

Tomcat_09_Editing_service-bat (SERVICE_NAME,PR_DISPLAYNAME)

Later let’s go to modify the description of this service:

set PR_DESCRIPTION=Tomcat 7.0.50 Server

Tomcat_10_Editing_service-bat (PR_DESCRIPTION)

To start TOMCAT when Windows does, we make the following change:

"%EXECUTABLE%" //IS//%SERVICE_NAME% --Startup auto

Tomcat_11_Editing_service-bat (EXECUTABLE)

You can also set the directory where all web applications will be deployed, for this demostration, I made a new folder named Webapps located inside of ServerWeb.

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.xml will be:

      <Host name="localhost" appBase="C:/ServerWeb/Webapps"
            unpackWARs="true" autoDeploy="true">
      <Context path="" docBase="http"
            reloadable="true" />

Tomcat_12_Editing_server-xml (Host name, Context path)
With this configuration is possible to deploy applications in other folder different to initially established by default configuration.


Enabling File Uploads.

You may need to upload files, need to make changes to the file web.xml

Insert the multipart-config element to enable permanently for all applications file uploads, you can use the optional attributes max-file-size and max-request-size like here among others.

        <multipart-config>
          <max-file-size>3145728</max-file-size>
          <max-request-size>5242880</max-request-size>
        </multipart-config>

Tomcat_13_Editing_web-xml (multipart-config,max-file-size,max-request-size)
max-file-size The maximum size allowed for uploaded files, in bytes:
3145728 = 3 * 1024 * 1024
max-request-size The maximum size allowed for a multipart/form-data request, in bytes:
5242880 = 5 * 1024 * 1024


Changing the Compilers of Tomcat.

Some times is needed to change the Compilers of Tomcat, to do this we will need to change the web.xml file, according if you need change compilerSourceVM or compilerSourceVM:

        <init-param>
          <param-name>compilerSourceVM</param-name>
          <param-value>1.7</param-value>
        </init-param>
        <init-param>
          <param-name>compilerTargetVM</param-name>
          <param-value>1.7</param-value>
        </init-param>

Tomcat_21_Editing_web-xml (compilerSourceVM,compilerTargetVM)


Connecting Tomcat with Httpd.

We will need mod_jk module, when a page request comes in, if the request should be handled by Tomcat, Httpd the request to Tomcat via the connector (mod_jk module).

We need to download JK connector, currently is Tomcat Connectors 1.2.37 for Win32, hence the mod_jk.so file is extracted and copied into the Tomcat’s folder.

Within the conf folder create a file called workers.properties where is defined the Tomcat workers whose content is:

worker.list=ajp13
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13

Tomcat_14_Creating workers-properties

Inside the folder conf also create a file called mod_jk.conf with content:

<IfModule !mod_jk.c>
  LoadModule jk_module "C:/ServerWeb/Tomcat/mod_jk.so"
</IfModule>
JkWorkersFile "C:/ServerWeb/Tomcat/conf/workers.properties"
JkLogFile "C:/ServerWeb/Tomcat/logs/mod_jk.log"
JkLogLevel info
<VirtualHost *:*>
  JkMount /*.jsp ajp13
</VirtualHost>

Tomcat_15_Creating_mod_jk-conf


Enabling MySQL to Tomcat.

To use MySQL with Tomcat is necessary to include the package allows, this package is called Connector/J. I downloaded called Connector/J 5.1.28 – Platform Independent and extracted the file named mysql-connector-java-5.1.22-bin.jar pasting it into the lib subdirectory of the Tomcat installation folder:

C:\ServerWeb\Tomcat\lib\


Operating the Tomcat Service.

We can to make the installation:

service.bat install

Tomcat_16_Installing

You can to start this service:

startup.bat

Tomcat_17_Starting

To stop this service:

shutdown.bat

Tomcat_18_Stopping

And remove it:

service.bat remove

Tomcat_19_Removing


HTTPD


Preparations for the Httpd installation.

I will use the Httpd 2.4.7 for Win32.
The contents of the .zip file was uncompressed in the folder:

C:\ServerWeb\Httpd_2.4.7\

But with symbolic link all operations of Httpd will be done under the folder:

C:\ServerWeb\Httpd\

To create the symbolic link for Httpd, use the command:

mklink /J "C:\ServerWeb\Httpd" "C:\ServerWeb\Httpd_2.4.7"

Httpd_00_mklink for Httpd

If you want to remove this link, you can use:

rd "C:\ServerWeb\Httpd"

Httpd_01_rd for Httpd


Working with the HTTPD configuration file httpd.conf.

Inside of conf subdirectory of Httpd folder there is one file containing the configuration of httpd with the name httpd.conf, this file need to be edited according to our requirements.

Edit the ServerRoot parameter updating the actual installation path.

ServerRoot "C:/ServerWeb/Httpd"

Httpd_02_Editing_httpd_conf (ServerRoot)

Edit the ServerAdmin parameter to the email address of the server administrator.

ServerAdmin joseluisbz@gmail.com

Httpd_03_Editing_httpd_conf (ServerAdmin)

Change the ServerName parameter to the server name and port to use.

ServerName ServerWeb:80

Httpd_04_Editing_httpd_conf (ServerName)

We edit the DocumentRoot (To set the directory from which httpd will serve files) and Directory (to define policies that only apply to the directory and subdirectories) parameters.

DocumentRoot "C:/ServerWeb/Webapps/http"
<Directory "C:/ServerWeb/Webapps/http">

Httpd_05_Editing_httpd_conf (DocumentRoot, Directory )

To avoid the directory listing when there isn’t index file, we delete the Indexes option.

    Options FollowSymLinks

Httpd_06_Editing_httpd_conf (Options )

To establish the order of precedence of predefined file to be displayed, we modify the value of DirectoryIndex parameter.

    DirectoryIndex index.php index.jsp index.html

Httpd_07_Editing_httpd_conf (DirectoryIndex )

For future use of CGI establish the required parameters.

    ScriptAlias /cgi-bin/ "C:/ServerWeb/Httpd/cgi-bin/"

Httpd_08_Editing_httpd_conf (ScriptAlias )

<Directory "C:/ServerWeb/Httpd/cgi-bin">

Httpd_09_Editing_httpd_conf (cgi-bin)

As you can see, here are the proposed changes have been completed.
Httpd_CountLines_00 Httpd


Including handling PHP to Httpd.

PHPIniDir indicates the folder where php.ini is located.
LoadModule php5_module loads the module that allow to Httpd handle Php files.
AddType indicates the extension to be identified or related with Php.

PHPIniDir "C:/ServerWeb/Php/"
LoadModule php5_module "C:/ServerWeb/Php/php5apache2_4.dll"
AddType application/x-httpd-php .php

Httpd_CountLines_01 Php


Including the Tomcat Connector to Httpd.

Include indicates where is located the configuration of Tomcat Connector.

Include "C:/ServerWeb/Tomcat/conf/mod_jk.conf"

Httpd_CountLines_02 Tomcat


Operating the Httpd Service.

We can to make the installation:

httpd.exe -k install -n "Httpd2.4.7" -f "C:\ServerWeb\Httpd\conf\httpd.conf"

Httpd_10_Installing

You can to start this service:

httpd.exe -k start -n "Httpd2.4.7"

Httpd_11_Starting

You can to restart this service:

httpd.exe -k restart -n "Httpd2.4.7"

Httpd_12_Restarting

To stop this service:

httpd.exe -k stop -n "Httpd2.4.7"

Httpd_13_Stopping

And uninstall it:

httpd.exe -k uninstall -n "Httpd2.4.7"

Httpd_14_Removing


Testing the Httpd (Php, Jsp) Installation.

Once you have followed the steps can test your installation.

Testing jsp pages.
Testing Installation Index-jsp

Testing php pages.
Testing Installation Index-php


I’m native Spanish speaker, please tell me English Language corrections.

Acerca de joseluisbz

Hasta ahora, espero actualizarlo después, ahora no.
Esta entrada fue publicada en Apache, Apache Lounge, databases, Httpd, Instalación, Install, Java, JSP, Manually Installation, MySQL, PHP, Servidores Web, Software, Tomcat, Web Server, Windows y etiquetada , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , . Guarda el enlace permanente.

Deja un comentario