Install Web Server in Windows XP with Apache2, PHP5 and MySQL4 – Part 3

Part 3 – Install PHP 5

Unzip the PHP zip package that downloaded in Part 1 to C:\PHP (Create a new folder named PHP at C:\ root level). Then shut down Apache server.

Open the Apache httpd.conf with a text editor and add two lines of code:

LoadModule php5_module C:/php/php5apache2.dll
AddType application/x-httpd-php .php

Added .php extension to show how to parse .php files

Note also the directory in load module points to where we installed PHP. So if you install PHP at other location, change it accordingly. The directory style should be / too instead of common DOS \.

These two lines can be added to the bottom of the httpd.conf file. However, note that modules in the load list are in reverse-priority order; those that come later can override or pre-empt those listed earlier. Therefore, adding php_mod at the end of the list can have unexpected results, such as disabling mod_rewrite (and other modules) for any php files that exist (mod_rewrite will run fine if the file doesn’t exist). The same error can disable mod_auth and other important modules. In summary, php_mod should be loaded before any modules you wish to run before your php code is executed. See the note in the Apache AddModule documentation for how to find the recommended ordering.

Next, copy/paste “php.ini-recommended” to C:/Program Files/Apache Group/Apache2 (or your Apache installation path), and rename it to php.ini. Restart the Apache server.

Testing php5 Installation

Create a file with the following contents and save it to the root web folder (C:/Server/htdocs or default C:/Program Files/Apache Group/Apache2/htdocs/) as “php5info.php”.

<?php
phpinfo();
?>

Access the following url http://localhost/php5_info.php. The complete PHP setting should be displayed on the browser. If there is an error or nothing been shown, there is problem with installation. Try the installation procedures again.

Enable MySQL extension

The php.ini that copied from php.ini-recommended already being set to optimum setting, so there is no special need to edit it. However, it still need to edit to enable mysql extension.

Open php.ini in the Apache2 directory with text editor.

Search for the line of extension_dir = “./”. Change it to extension_dir = “C:\php5\ext”. Also, uncomment the line of extension=php_mysql.dll.

Save the php.ini. Restart the Apache server. Re-try to access http://localhost/php5_info.php. It should working fine. If not try to check what’s the cause of errors, which most likely due to wrong extension_dir or missing extension. Or you may try to copy all the needed extentions (with .dll extenstion) to Apache2 directory.


17 Responses to “Install Web Server in Windows XP with Apache2, PHP5 and MySQL4 – Part 3”

  1. james van leuvaan
    March 1st, 2009 12:24
    17

    There is an error in the copy/paste code written for Apache2.2.11 with php5

    Here is the proper LoadModule method:


    # php
    LoadModule php5_module “C:/php/php5apache2_2.dll”
    <IfModule php5_module>
    AddType application/x-httpd-php .php
    </IfModule>

    My Configuration:

    1: Windows XP Professional SP3
    2: Apache 2.2.11
    3: PHP 5.2.6

    Also, it is fine to uncomment all the extensions in the php.ini.

    I migrated from an IIS 6.1 installation to an Apache installation to test J2EE on Apache2, using MySQL, postgreSQL, MSSQL

  2. TIGABEATS.COM
    November 13th, 2008 05:22
    16

    Amit,

    try putting in the ip address of the host computer instead of localhost.

  3. TIGABEATS.COM
    November 13th, 2008 05:20
    15

    Hey for the once that apache returns error saying it cannot load the php module, the reason behind this is apache doesnt support php5.1, they say they will only support 5.2 but luckily theres a fix,

    in httpd.conf include php5apache2_2.dll instead of php5apache2.dll.

    the “_2″ special module version works just fine.

  4. Amit
    October 19th, 2008 12:02
    14

    I install apache2.2.9, php5 and Mysql5 on windows XP, ican see php info page and php scripts from my machine, But when i try from any other machine on network it gives me error page can not be shown. can you help me in accessing page from other machine on network.

    Thanks.

  5. Handril
    June 21st, 2007 13:10
    13

    I have succes install apache 2, php5 and MySQL 5. I can display php info. But, why php script that I make can not run in the IE browser. this simple script like this:

    I use Windows XP.

    Thank you for your attention.

  6. Asokan
    February 25th, 2007 01:30
    12

    I am trying to connect mysql5 from apache2 but
    browser showing an error

    Warning: require(/config/db_config.php) [function.require]: failed to open stream: No such file or directory in C:\webroot\dbconnect.php on line 2

    Fatal error: require() [function.require]: Failed opening required ‘/config/db_config.php’ (include_path=’.;C:\php5\pear’) in C:\webroot\dbconnect.php on line 2

    I am using,MySQL5, PHP5 and Apache2.2 running windows xp
    Request your help
    Thanking you
    Asokan

  7. Asokan
    February 25th, 2007 01:30
    11

    I am trying to connect mysql5 from apache2 but
    browser showing an error

    Warning: require(/config/db_config.php) [function.require]: failed to open stream: No such file or directory in C:\webroot\dbconnect.php on line 2

    Fatal error: require() [function.require]: Failed opening required ‘/config/db_config.php’ (include_path=’.;C:\php5\pear’) in C:\webroot\dbconnect.php on line 2

    I am using,MySQL5, PHP5 and Apache2.2 running windows xp
    Request your help
    Thanking you
    ******

  8. JaD
    February 19th, 2007 17:23
    10

    u forgot a thing, for the apache..
    modify DirectoryIndex and put index.php
    in rest is a good tutorial :P

  9. JaD
    February 19th, 2007 17:11
    9

    You said…

    Search for the line of extension_dir = “./”. Change it to extension_dir = “C:\php5\ext”. Also, uncomment the line of extension=php_mysql.dll.

    Save the php.ini. Restart the Apache server. Re-try to access http://localhost/php5_info.php. It should working fine. If not try to
    …..
    …..
    “C:\php5\ext”. ?????? — the correct line is
    “C:\php\ext”.

  10. cary
    October 7th, 2006 07:18
    8

    With Apache 2.2, you will need PHP 5.2.x. It has the php5apache2_2.dll that is compiled for the new version. You can download a stable build at http://snaps.php.net/

  11. Tom
    September 10th, 2006 20:48
    7

    There seems to be a problem with Apache 2.2 and the PHP dll modules (on Windows obviously, don’t know if there are any problems on unix). I fixed it by going to http://www.apachelounge.com/download/ and downloading their version of the php4apache2.dll file. This also comes with another file which you have to put in your Apache/bin directory, and you will also need to download a MS Visual C++ Package if you don’t have the .NET framework installed. This is all explained in the readme file that comes with the DLL.

  12. greg
    July 13th, 2006 08:43
    6

    I got it to work i uninstalled apache 2.2 and installed 2.0 and followed your steps again and now it is all working:)

    Thank you for the help!

  13. greg
    July 13th, 2006 07:32
    5

    ok i reset it and now the server cannot find php5apache2.dll? It is in the php folder. I am using php5.1.4 and apache2.2.2!

  14. Administrator
    July 12th, 2006 19:46
    4

    Looks like your web server doesn’t parse PHP file and treat it as text file, follow the steps carefully.

  15. greg
    July 12th, 2006 19:10
    3

    I have the server set up and i can read a php file if i start it withhtml tags but it doesnt read the php script i put in. if i dont use the html tags i get a download box when i click on the link to test the php?? can u help me!!

  16. Administrator
    May 20th, 2006 14:33
    2

    Hi Todd, the issue might be related to mod_perl (if you’re using it as ActivePerl). If you install Apache/2.2, please use mod_perl that is compiled with Apache 2.2 and not Apache 2.0 for compatibility issue.

  17. Todd
    May 20th, 2006 03:42
    1

    well, I have followed your directions and everyone else’s before this, but no luck. After adding the module declaration in the httpd.conf file, when I restart apache i get – syntax error: cannot load specific module. all of my paths are correct what is the problem?

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe to comments feature has been disabled. To receive notification of latest comments posted, subscribe to My Digital Life Comments RSS feed or register to receive new comments in daily email digest.
Custom Search

New Articles

Incoming Search Terms for the Article

error trying access httpd.conf file - error trying access httpd.conf file. you will need to manually configure the web server - error trying to access httpd.conf file - error trying access httpd.conf file. you will need to manually configure the web server. - error trying access httpd.conf - Error trying to access httpd.conf file. You will need to manually configure the web server - php install error trying access httpd.conf - php error trying to access httpd.conf file - error trying to access httpd.conf - php5 apache windows - error trying to access httpd.conf file php - how to enable php on apache2 - apache php xp - php5 apache2 windows - php error trying access httpd.conf file - apache2 php5 - php error trying access httpd.conf file. you will need to manually configure the web server - php5 apache2.2 - apache2 php5 windows - php error trying to access httpd.conf - apache syntac loadmodule php windows - apache 2 enable php - apache2.2 php5 - error trying to access httpd.conf file when installing php - apache2 xp php - php5 for apache2 - how to install php5 and apache on windows xp - php install error trying access httpd.conf file - php error trying access httpd.conf - install php5 for testing scripts offline windows xp - php5 apache2 loadmodule - apache2.2 php - "error trying access httpd.conf file" - apache install php5 - apache2 php5 module - apache php windows xp installation - php5 for apache2.2 - php apache2.2 - apache php windows loadmodule - Error trying htppd.conf - error trying to acces httpd.conf - windows apache php5 module - apache2 windows php - XP install apache php5 - parse php+xp+apache - php error access httpd.conf - install php apache 2.2 on windows - mod_auth.so httpd 2.2.11 missing - PHP install error trying to access httpd.conf file - php local install error configuring httpd.conf file -