Tuesday, June 24, 2008

Integrate php with MySQL

Open {PHP_DIR}/php.ini
1) Check if the extension directory is set correctly. is is set incorrectly in the php.ini file that ships with the installer. In that , Replace extension_dir="./" with extension_dir="./ext/"
(2) Uncomment extension=php_mysql.dll
(3) You should now be able to access your mysql database.

Integrate Apache 2.x with Php 5

Open {APACHE_DIR}/conf/httpd.conf
1) Enable mod rewrite by uncommenting or adding LoadModule rewrite_module modules/mod_rewrite.so

2) Add the following lines in the load module section
PHPIniDir "C:/Program Files/php"
LoadModule php5_module "C:/Program Files/php/php5apache2_2.dll"

3) Add php mime type
(a) Search for "IfModule mime_module" tag
(b) Add the following lines right after the "TypesConfig conf/mime.types"
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php .html

(4) Allow full control to Apache's root folder that contains php files by creating or modifying (if one already exists) the <Directory> element for the root folder. Since the root folder for php is {APACHE_DIR}/htdocs folder itself on my machine, the directory entry looks like this:-

Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all


(5) Test the setup. Create a new file called info.php under {APACHE_DIR}/htdocs folder. Copy & paste the following lines into info.php
<?php
phpinfo();
?>>


(6) Access info.php from the browser . The integration with Apache is successful if you see a page that lists information about the php environment installed on your machine.

Installing php5

On Windows XP Pro:-
1) download php's installation zip file from http://www.php.net
2) Unzip the files to "C:/Program Files/php" folder
3) Add "C:/Program Files/php" to the PATH environment variable. Right click My Computers->properties->Advanced->Environment Variables. Update PATH variable under system variables section.
4) rename php.ini-dist as php.ini under "C:/Program Files/php" folder
5) Restart PC. This makes the os load all files residing in "C:/Program Files/php" folder.
6) After restart, open command line window (start->run->cmd.exe) and run php -version
7) The installation is successful if the php interpreter shows version information without any errors or exceptions

Tuesday, June 10, 2008

Integrate Apache Web Server 2.x with Tomcat 6.x on Windows XP

1) Enable Apache's HTTP proxy module by uncommenting the following lines in {APACHE_DIR}/conf/httpd.conf

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

2) Right at the end of the Load module section in httpd.conf, register URLs that should be forwarded to Tomcat like this:-
ProxyPass relative_url translated_url

For ex, Accessing a web application named 'tp' deployed on a local Tomcat server listening on port 8080 through Apache's http proxy (http://localhost/tp) would like this:-
ProxyPass /tp http://localhost:8080/tp

3) Add Apache's proxy to Tomcat's <connector> element associated with port 8080 in {TOMCAT_DIR}/conf/server.xml by adding the proxy attributes like this:-
<connector port="8080" protocol="HTTP/1.1"
connectiontimeout="20000"
redirectport="8443"
proxyName="localhost"

proxyPort="80"/>

That's all there is to it. You should now be able to access tomcat via Apache Web Server's HTTP reverse proxy.