How to install Apache, PHP 4, and MySQL under Windows?

MyEgo.cz

home foto blogy mywindows.cz kontakt

How to install Apache, PHP 4, and MySQL under Windows?

PHP 04.04.04
windows

This article aims to provide a full reference for installing and configuring Apache 2 web-server, with mod_rewrite, PHP 4.3.5 scripting language, iconv PHP extension, and MySQL 4 database under Windows. PHP 4 will can be installed / configured as Apache 2 module or CGI script, but installing it as a module is a recommended approach. This "How To Manual" was fully tested under Windows XP SP1, but shall work with any Windows version.

First, you will need to download following files:

  • binary form of Apache 2.0.49 (file apache_2.0.49-win32-x86-no_ssl.msi).
  • PHP 4.3.5, I also recommend to download a PHP manual (in .chm file format).
  • MySQL 4.0/4.1, including its manual and documentation.
  • I also recommend to download from mysql.com utility called MySQL Control Center (current version 0.9.3), which is more comfortable to use than phpMyAdmin (which your web-hosting probably provides).

Download binary form of all files from links provided.

If you do not want to configure anything, especially httpd.conf a php.ini, you can download a prepared configuration of all these files ;) Everything will work immediately, just unpack and copy over you existing files.

This assumes that:

  • Apache 2.0.49 web-server is installed under c:/program files/apache group/apache2.
  • PHP is installed under c:/php/
  • Web is located under c:/www/

When installing Apache, PHP and MySQL, always select a "default installation", no special configuration is needed at this time. After finishing installation, you will have to download configuration file provided, or make manual adjustments to these files:

  • httpd.conf: at c:/program files/apache group/apache2/conf/.
  • php.ini: at c:/php/

Setting-up Apache with mod_rewrite:

(this means modifying file c:/program files/apache group/apache2/conf/httpd.conf)

Setting-up DocumentRoot:

DocumentRoot "C:/www"
ServerName localhost
ServerAdmin your@email.com

Module mod_rewrite:

LoadModule rewrite_module modules/mod_rewrite.so

Allow .htaccess:

<Directory>
 Options FollowSymLinks
 AllowOverride None
</Directory>
<Directory "C:/www">
 Options Indexes Includes FollowSymLinks MultiViews
 AllowOverride All
 Order allow,deny
 Allow from all
</Directory>

Dissalow clients to access .htacces:

<Files ~ "^.ht">
   Order allow,deny
   Deny from all
</Files>

Install PHP as a CGI skript - NOT recommended:

ScriptAlias /php4/ "C:/php/"
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
AddType application/x-httpd-php .php4
Action application/x-httpd-php "/php4/php.exe"

Install PHP as a module - recommended:

LoadModule php4_module "c:/php/sapi/php4apache2.dll"
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
AddType application/x-httpd-php .php4

Add index.php to Apache search pattern:

DirectoryIndex index.html index.htm index.php

PHP settings

(you need to modify file c:/php/php.ini, assuming PHP installation at C:/php/):

; report all errors
error_reporting  =  E_ALL
display_errors = On
; set to On, if your scripts do not work,
; but your scripts should be able to work in
; Off setting as well; this is more secure
register_globals = Off
; includes and extensions
include_path = ".;c:phpincludes"
extension_dir = "c:phpextensions"
; iconv support
extension=php_iconv.dll
; mbstring support
extension=php_mbstring.dll
; smtp
SMTP = smtp.email.com
sendmail_from = your@email.com
[MySQL]
; Allow or prevent persistent links.
mysql.allow_persistent = On
[Session]
session.save_handler = files 
session.save_path = "c:/php/tmp"
session.use_cookies = 1 
session.name = PHPSESSID 

What's left?

Finally, copy

  • all files from c:/php/dlls/ into c:/windows/system32/
  • file c:/php/php4ts.dll into c:/windows/system32/
  • file c:/php/php.ini into c:/windows/system32/ and c:/windows/

Now, you can restart your computer for changes to take effect. Installation and configuration is complete!

Oh, btw, default MySQL username is "root" and password is empty, "". :)

If you are using mod_rewrite and .htaccess and getting "No input file specified." error, add following to PHP.INI file:

cgi.fix_pathinfo=1

Testing

Want to test your installation? Create, under DocumentRoot, file index.php with the following content:

<html>
<head><title>PHP Test</title></head>
<body>
<? phpinfo(); ?>
</body>
</html>

This will display 5 pages of info about Apache and PHP configuration.


Komentáře

  1. 1 Patrick LOGE 09.04.04, 11:04:45
    FB

    According to the PHP web site, server API versions for Apache2 is "experimental".

    Doesn't seem good enough for a production server.

    What do you think ?

  2. 2 Radek Hulán 10.04.04, 10:04:45
    FB

    [1] that's what the docs says, but.. it's rock-stable on my system. There were some problems in release 2.0.0-2.0.20, but 2.0.48-49 seems to be great.

  3. 3 Vamsee 16.04.04, 04:04:51
    FB

    Hi folks,

    I am novice to configuring the apache with the php.I am on Windows 2000 prof, apache 1.3 php 4.X and IMP 3.2.3 for installing webmail, the following error appears when I key in

    http://mis3.eslha.local/log... in the browser

    Warning: main(c:imp3.2.3lib/../../lib/browser.php): failed to open stream: No such file or directory in c:imp3.2.3libbase.php on line 25

    Fatal error: main(): Failed opening required 'c:imp3.2.3lib/../../lib/browser.php' (include_path='.;c:phpincludes') in c:imp3.2.3libbase.php on line 25

    I was able to run the test PHP file, but was a failure to run the above:cry:

    Please help me out. Thanks in advance

  4. 4 Radek Hulán 16.04.04, 10:04:26
    FB

    [3] I have no clue what that means.. Guess not a PHP / Apache, but application (Webmail) configuration error?

  5. 5 mark 08.05.04, 02:05:12
    FB

    my php release 5 has no dll folder in c:/php

    please help

  6. 6 Radek Hulán 08.05.04, 05:05:12
    FB

    [5] I have no idea, do not use PHP 5, as it is not a final release, so all webhostings do offer 4.x only... You should test on same PHP version as your webhosting offeres.

  7. 7 Robert McGovern 19.05.04, 06:05:02
    FB

    [3] I've just gone through this. (setting horde and imp up) The problem is file permissions.

    I had cygwin installed and could see that everything in the horde directories and imp where rwx------.

    From the cygwin prompt (in the horde directory) I typed

    chmod -R og+rx *

    which recursivly decends the file try setting permissions so that the files can be read (and executed) by other users than you. (for instance SYSTEM)

    HTH's

    Rob

  8. 8 Oussama (OZ) Mubarak 01.07.04, 05:07:33
    FB

    I installed apache 2.0.50, php 4.3.7, and mysql 4.0.20d on WinXP Pro as described above, I get the error: "Cannot load C:/PHP/SAPI/php4apache2.dll into server: The specified module could not be found."

    I don't have that file in the SAPI folder or enywhere else, but I have a php4apache.dll so I tried to change the name of it to php4apache2.dll. But the same error occurs even after restarting windows.

    Any ideas where I might have gone wrong??

    Thank you.

  9. 9 DmX_Raze 23.08.04, 11:08:33
    FB

    All I can say is whoever put page of info together is a complete and utter genius. Thank You Thank You Thank You Thank You Thank You Thank You Thank You Thank You Thank You Thank You Thank You Thank You Thank You. THANNNNNNNNNNNNNNK YOUUUUUUUUUUUUUUU !!!!

  10. 10 Shawn Anderson 12.09.04, 05:09:55
    FB

    [8][8]

    I keep getting this same error as well. I'm going nuts trying to figure out what the problem might be. Anyone have any suggestions?

  11. 11 mr_avril 04.10.04, 04:10:07
    FB

    [5] don't used the .exe installer.. get the manual one.. exe installer don't include dll files.. in php.net , they serve two installer, one as .exe and one as .zip. Zip file there is much bigger than .exe because it contains all the files that not in .exe...

  12. 12 mr_avril 04.10.04, 04:10:18
    FB

    I have install apache2, php 4.3.9 and mySQL4.. i used your configuration and the document root would be as you stated c:/www
    I test my installation with the simple coding you gave with the name index.php (that display the php page..)

    then when i want to serve my web site.. my web site using the same index.php name..
    the prob is when i link to the address (http://<my ip>/index.php .. it keep showing the php page like the one i do for the testing (test after installation)..it did not direct to my web page as it suppose to..
    Does this mean i cannot use index.php name or is it something i can make to fix this?

    thanks

  13. 13 mr_avril 05.10.04, 02:10:18
    FB

    another prob..
    i test with this coding..

    <?

    $query = "php";

    $query = ereg_replace(" ","+",$query);
    $submit_url = "http://www.google.com/search?q=...$query";

    $file = fopen($submit_url, "r");
    $rf = fread($file, 50000);

    echo($rf);

    ?>
    and it gave me this error...

    Warning: fopen(http://www.google.com/search?q=php...): failed to open stream: Bad file descriptor in C:wwwtest1.php on line 8

    Warning: fread(): supplied argument is not a valid stream resource in C:wwwtest1.php on line 9
    Seems like it cannot open the link..You know why? i don't what else to do.. I used this coding to construct my website.. Someone told me i must used latest version of php..and others said maybe with my web server installation.. i don't think the coding is wrong.. so i suspect it is because of my installation..i've followed exactly this tutorial on installing apache,php and mysql..so i guess its suppose to work..i don't know..so any idea??

    Really appreciate ur help..thanks!!

  14. 14 srini 20.10.04, 11:10:25
    FB

    [12] Respond to mr_avril ; As I understand, your need to save the page in the doc root <some other name>.php. Try this new direction and hope may give desired result.