NameSilo

HOWTO: Install the Apache Web Server, Perl, PHP, and MySQL on Windows

Spaceship Spaceship
Watch
Impact
6
This tutorial is old and you can find a more up to date version here or here.

Code:
        //
       //  
      //Tutorial by deadserious - © [url]http://www.webdesigntalk.net[/url]
     //© 2003 [url]http://www.webdesigntalk.net[/url] 
    //REPUBLICATION OF THE TUTORIAL REQUIRES OUR PERMISSION.
   //[email protected] 
  //
 //
//

  • NOTES:
  • Click Here to view this tutorial outside the forum.
  • This tutorial was written using a Windows 98 Machine. The same basic steps should work on Windows ME/2000/XP.
  • If installing on another Windows version certain things will be slightly different such as how you stop and start services, but you should be able to figure it out.
  • This tutorial used the latest versions of Apache and PHP which aren't fully supported/tested yet, but well this is just for learning and testing on your home computer and everyone will eventually need to upgrade to these versions anyways.
  • This tutorial shows you how to set up PHP as a CGI binary. I havn't succeded in setting up PHP as an Apache module with Apache 2.0 on Windows yet, but if and when I do I'll update this tutorial.
  • This tutorial was set up to make things similar to most hosts out there. So when you're done testing your scripts and pages you wont have to make so many changes when you're ready to upload them on to your hosts server.
STEP 1: Check and see if you have Microsoft windows installer:
Go to Start --> Run --> Type MSIEXEC in the input box and hit enter to see if it's installed and what version. You need to have atleast version 2.0. You will see a message box that says "Incorrect command line parameters", along with the version number. You can install or upgrade with the following downloads if you need to: Windows Installer 2.0 Redistributable for Windows 95, 98, and Me

Windows Installer 2.0 Redistributable for Windows NT 4.0 and 2000:

STEP 2: Download and install the Apache Web Server:
http://nagoya.apache.org/dist/httpd/binaries/win32/ Download the latest stable release that ends with the .msi extension apache_2.X.XX-win32-x86-no_ssl.msi. Make sure the version you download has no_ssl or no_src in it. Click on the installation program you just downloaded until you see:

Welcome to the installation Wizard for Apache HTTP Server 2.0.43
Continue through the set up, accept the license agreement, continue until you get to the screen that says:

Server Information
Please enter your servers information

Enter "localhost" without the quotes in the Network Domain input box.

Enter "localhost" without the quotes in the Server Name input box.

Enter any email address you'd like to in the Administrator's Email input box.

Click Next --> Click Next

You'll have an option to change the installation to a different folder.

Click Change

Enter "C:" without the quotes for the folder name.

Click OK --> Click Next --> Click Install --> Click Finish

Apache should now be installed in the C:Apache2 directory.

STEP 3: Configure Apache to enable some good stuff.
Browser to the directory where the httpd.conf file is located: C:Apache2conf

Open up httpd.conf with your favirote text editor and:

3A Search For:
Options Indexes FollowSymLinks

Replace With:
Options Indexes FollowSymLinks MultiViews +Includes

3B Search For:
AllowOverride None

Replace With:
AllowOverride All

3C Search For:
DirectoryIndex index.html index.html.var

Replace With:
DirectoryIndex index.html index.html.var index.htm index.php index.shtml

3D Search For:
<Directory "C:/Apache2/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>

Replace With:
<Directory "C:/Apache2/cgi-bin">
AllowOverride All
Options ExecCGI
Order allow,deny
Allow from all
</Directory>

3E Search For:
AddType application/x-tar .tgz
AddType image/x-icon .ico

Replace With:
AddType application/x-tar .tgz
AddType image/x-icon .ico
ScriptAlias /php/ "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 /php/php.exe

3F Search For:
#AddHandler cgi-script .cgi

Replace With:
AddHandler cgi-script .cgi .pl

3G Search For:
#AddOutputFilter INCLUDES .shtml

Replace With:
AddOutputFilter INCLUDES .shtml

Jump down to step 7A to test and verify apache is working.

STEP 4: Download and install Perl:
http://activestate.com/Products/Download/Download.plex?id=ActivePerl ActivePerl 5.8.0 build 804 Windows MSI 11.5MB. Click on the Perl installation file you downloaded and accept the license agreement and continue until you come to the screen that says:

Custom Setup
Select the way you want features to be installed
Click the browse button and change the location from:
C:Perl
to:
C:usr

Click Next --> Click Next --> Click Next --> Click Install -->Wait for it to install --> Click Finish

Jump down to step 7B to test and verify Perl is working.

STEP 5: Download and Install PHP
http://www.php.net/downloads.php Scroll down until you see Windows Binaries. Download the latest stable zip version and not the installer version. PHP 4.3.0 zip package.

Unzip it to your: C: directory

Browse to your: C: directory and look for the folder named php-4.3.0-Win32. This maybe be different if you downloaded a different version.

Open up the php.ini-dist file located in the php-4.3.0-Win32 folder and:
Search For:
doc_root =

Replace With:
doc_root = "C:Apache2htdocs"

Search For:
extension_dir = ./

Replace with:
extension_dir = "c:phpextensions"

Save the php.ini-dist file and rename it to: php.ini

Now move the php.ini file into your: C:Windows directory.

Find the php4ts.dll file located in your: C:php directory and move it to your: C:Windows directory.

Rename the: C:php-4.3.0-Win32 folder to: php

Jump down to step 7C to test and verify PHP is working.

STEP 6: Download and Install MySQL
http://www.mysql.com/downloads/download.php?file=Downloads/MySQL-3.23/mysql-3.23.54-win.zip

Unzip the file you just downloaded to a temporary directory. If your using a program such as Winzip and it gives you the option to install now go ahead and do that and choose all the default settings.

If not browse to the temporary directory where you unzipped the files and click on the setup.exe file to start the installation. Continue through the installation with all the default settings until your done.

Jump down to step 7D to test and verify MySQL is working.

STEP 7: Test Everything:

7A: Test the Apache Web Server
Start Apache
You can start apache by going to the Start Menu -- > Apache -- > Start apache in console on Windows 98. This may be different for other versions.

You'll see a little Dos like screen appear if your using Windows 98

Open up a text file and throw some HTML in it:
Example:
<html>
<body>
Apache Web Server Test
</body>
</html>

Save it as index.html in your C:Apache2htdocs directory.

This is where all your html, graphics, and php files will go.

Go to http://127.0.0.1 or http://localhost in your favirote browser and see if it works.

Note: You can stop apache on Windows 98 by double clicking in the little black dos box and Pressing Ctrl+C


7B: Test Perl / CGI
Open up a text file and place some code in it:

Example:

#!/usr/bin/perl
print "Content-type: text/htmlnn";

print "Hello Perln";

Save it into your C:Apache2cgi-bin directory as: perltest.cgi

Go to http://127.0.0.1/cgi-bin/perltest.cgi and see if it works.


7C Test PHP:
Open up a text file and add the the following code to it:
<?php
phpinfo();
?>

Save it in your C:Apache2htdocs directory as phpinfo.php

Browse to:
http://127.0.0.1/phpinfo.php and see if it works.


7D Test MySQL:
Browse to your C:mysqlbin directory and Click on the winmysqladmin.exe file.

This should launch a graphical user interface that you can use
to edit configuration files, and maintain and monitor your MySQL server.

You should see a screen with:
Create the mysql.ini file with default values and the user below. Reccomended to novice user. Enter a username and password that you will remember Click Ok.

You'll see a stoplight icon in your taskbar

You can stop the MySQL server and/or the WinMySQLAdmin tool by right clicking on the icon.

To login to the MysQL server from the command line:

Go to the Start menu -- > selct run.
Type dosprmpt in the input box to open up the command-line interface, or if that doesn't work try typing cmd in the input box.
That should open up a dos like screen.

Change your directory to the bin directory of MySQL by typing:

cd c:mysqlbin

And pressing enter.

Now you can type mysql and press enter to start the MySQL monitor. You should see something like:

Welcome to the MySQL monitor. Commands end with ; or g. and some more stuff. If you see that then you know MySQL is working.

You can use the MySQL administration tools like mysqladmin and mysqldump from the command-line to create, drop, dump, and restore databases and alot more.

To get a complete list of mysqladmin commands type the following at the prompt:

#prompt> mysqladmin --help


If you plan on running scripts that connect to a MySQL database you usually need to enter a database name in the config file of the script. If you just make up a name and run the install file for the script, it may create the database for you. If not you can either use the database name: test, or create one using the mysqladmin tool.

You don't need to enter a username or a password in the config file. You can use localhost as the database hostname or server name.

Okay that's all for now, I'll try and update this tutorial every so often, so keep checking back for updates!. :)
 
Last edited:
2
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Adding Frontpage to this Install

Super Post, thank you.

I've completed this entire list and it works great.

Next, I need Frontpage Extensions.

Are there any changes to make this work here?

:rolleyes:
 
0
•••
Cool, glad to see you got everything working. :D

I've never installed frontpage on windows with apache, so I really don't know if it will work or how to do it, but if it will work it's probably easy to install. This link may give you somewhere to start: http://support.microsoft.com/view/tn.asp?kb=300004
 
0
•••
3D Search For:
<Directory "C:/Apache2/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>

Replace With:
<Directory "C:/Apache2/cgi-bin">
AllowOverride All
Options ExecCGI
Order allow,deny
Allow from all
</Directory>

This is what I found:
<Directory "C:/Apache2/cgi-bin">
AllowOverride All

Options None
Order allow,deny
Allow from all
</Directory>

Should I still replace it?
 
0
•••
Well, you don't really need to unless you plan on executing cgi scripts. But it won't hurt anything if you do replace it with what's listed. The only difference would be adding in the Options ExecCGI. :)
 
0
•••
What should I do if the test does not work? Im running Windows XP home edition and double checked everything and still does not work.
 
0
•••
Does the Dos Window open when you go to your programs menu and then select start or run apache?
 
0
•••
Yes. The DOS window opens for a second and closes. I am also monitoring Apache and its running.
 
0
•••
Did you create an index.html file in your C:Apache2htdocs directory? And what happens when you try and access it?
 
0
•••
Ok i clicked on the index.html file in Apache folder and it worked. I was clicking on your test links and it wasnt working.

This is the link C:Apache2htdocsindex.html

Am I doing it correctly?
 
0
•••
Well when you go into the folder and click on the file, that's just like opening up the file from your desktop or any other folder, it's not running it on the server. It should work as http://localhost/index.html or http://127.0.0.1/index.html in your browser if you're using an up to date browser like IE6.

If you still can't get it working that way then I would say try and reboot your computer and see if it starts up by default and/or try stopping and restarting the service with the little service manger in your system tray and then try again and let us know if it works or not.
 
0
•••
Restarted computer and stop and start Apache and the test still doesnt work.
 
0
•••
Have you intalled the XP Service Pack 1: http://www.microsoft.com/windowsxp/pro/downloads/servicepacks/sp1/default.asp

If not, then you'll need to install that in order for it to work.

Also you may try going to your Start menu >Slect Run > Type "cmd" without the quotes in the input box to open up the command line interface, if that doesn't work, type "dosprmpt" instead. Then type the following commands pressing enter after each one:
net stop apache
net start apache

Try them things for now and let us know if any of it worked and we'll go from there.

Also do you have any type of firewall running?
 
0
•••
Yes service pack 1 is installed.

I also have Zonealarm but disabled it before installing and remained disabled during tests.
 
0
•••
It looks like there has been some problems with apache 2.x and zone alarm: http://www.apache.org/dist/httpd/binaries/win32/README.html

It may be that you have another service like IIS running on port 80. If you can determine if you have IIS installed and if it's running and then stop it that would probably solve the problem. Possibly check Start->Administrative Tools->Services and look for World Wide Web Services and make sure it's stopped and set it to manual start up.
 
0
•••
I disabled zonealarm when installing. Apache never stopped responding.

I believe IIS is only on windows 98 or 2k? Im running windows xp.
 
0
•••
You say apache is responding or do you mean it's running?

If you still haven't got it working you may try running it on a different port. Try editing your httpd.conf and search for "Listen 80" or something similar and change it to "Listen 8080" and then searching for "ServerName 127.0.0.1:80" and changing it to "ServerName 127.0.0.1:8080." Then try restarting the server and calling up your index.html file at http://127.0.0.1:8080 or http://localhost:8080. But, of course, make sure that you create the index.html file first.

If that don't work I would probably try uninstalling the 2.x.x.x version and installing 1.3.27 or 1.3.28 and see if one of them works our for you. Also if you still can't get it working if you want zip up your httpd.conf and attach it here so we can look at it.
 
0
•••
the same

Hi! I have the same problem with starting Apache on Windows XP. I will try the things that you said. But I've tried the most of them but...we will see. I thought that it is from my computer but after i've read that other persons have the same problem i think that there is just something specific on this Windows.
 
0
•••
Thanks for responding slyn4ice. I'm glad it wasnt just me. Im already building another machine to install redhat with this server.
 
0
•••
I'm happyyyyyyyyy!

Hey, people, version 1.3.27 started perfect! :) Try it! 10x for all :) Success! :)
 
0
•••
Hey, glad to see you got it working! I guess XP and apache2 don't like each other some times.
 
0
•••
...but now i can;t make php to work...:(

Php is making problems....I have dreamweaver mx on my pc and when i'm writting a php file it goes to open the page with dreamweaver mx...but it opens just a white page....when i'm writting forms in html and i'm using php....it's doing strange things too...i'm writting the asked information in the form and when i submit....it's not showing me the expected result...
It shows me a part from the php code....:( what i must do?
i need php very urgently because i'm doing a project and i must finish it before december. ;(
 
0
•••
Since you installed a 1.3.x version the configuration will be a little different and you can install PHP as an apache module. Here's some instructions below that should help you get it up and running.

Download and Install PHP
http://www.php.net/downloads.php Scroll down until you see Windows Binaries. Download the latest stable zip version and not the installer version. PHP 4.3.0 zip package.

Unzip it to your: C: directory

Browse to your: C: directory and look for the folder named php-4.3.0-Win32. This maybe be different if you downloaded a different version.

Open up the php.ini-dist file located in the php-4.3.0-Win32 folder and:
Search For:
doc_root =

Replace With:
doc_root = "C:Apachehtdocs" <-- Replace this with your actual path to your htdocs directory.

Search For:
extension_dir = ./

Replace with:
extension_dir = "c:phpextensions"

Save the php.ini-dist file and rename it to: php.ini

Now move the php.ini file into your: C:Windows directory.

Make sure the files php4ts.dll and php4apache.dll are located in your C:php-4.3.0-Win32 directoy. If they are not there you should be able to find them in one of the subdirectories (ex: C:php-4.3.0-Win32sapi) and copy them from there into C:php-4.3.0-Win32

Rename the: C:php-4.3.0-Win32 folder to: php

Configure Apache 1.3.x to run PHP

Open up your httpd.conf file located in your conf directory and

Search For:
#LoadModule unique_id_module modules/mod_unique_id.so
and add this right below it:
LoadModule php4_module "c:/php/php4apache.dll"

Search For
AddModule mod_setenvif.c
and add this right below it:
AddModule mod_php4.c

Search For:
AddType application/x-tar .tgz
and add this right below it:
AddType application/x-httpd-php .php

You can create a file named info.php located in your htdocs directory with the following code to test it:
<?php
phpinfo();
?>

Start apache and browse to: http://localhost/info.php
 
0
•••
Originally posted by TSN
I disabled zonealarm when installing. Apache never stopped responding.

I believe IIS is only on windows 98 or 2k? Im running windows xp.


iis is avalible in xp, go to ad and remove and select the windows components thingy bob and its in there it doesnt get installed by default
 
0
•••
YES! It started to work normally!
Thank you very much!
 
0
•••
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back