Articles – Running Apache in Windows

Running Apache in Windows 2000

I have learnt the hard way that Apache is so much easier to configure compared to Internet Information Server (IIS). I wanted a web server to host a Intranet site at my work place and the server is running Windows 2000 (Win2k) and there’s no way I can pop in a Linux server so I have to do with the Win2k server. Configuring mySQL was easy enuff but PHP really took me 3 whole hours! OK, I am slow and read through a lot of documentations, fiddling around and checking my e-mail account(s), surfing the web in between but cos’ it’s wasting too much of my time. ;P

So finally, I decided to dump IIS and give Apache a try. My experience with Apache was great as it gave me no problem as it’s installed (together with PHP and mySQL supported) on my home Redhat system when installing Redhat. Now, I have to try figure out how to get Apache, PHP and mySQL onto this Windows 2000 server. Did I mention that Apache is open source, so is PHP and mySQL!

For this article, I will not be showing you Windows 2000 as it’s a production server (meaning it’s in full use), I (my boss actually hehe) cannot afford it to have downtime even for my Intranet. I’ll be showing you how to run a Apache server with mySQL and php installed. And of course we’ll test it in the process and I don’t think there better way than to install phpBB! In the process, you will learn how to get, install and configure Apache, install PHP and get it working with Apache, create a mySQL database and use it. That’s informative!

1. What you need
2. Apache HTTP Server
3. mySQL
4. PHP

1.0 What you need

1.1 Apache HTTP server

Download it @ http://httpd.apache.org/download.cgi

I’ll be downloading “Win32 Binary (MSI Installer): apache_2.0.44-win32-x86-no_ssl.msi”

1.2 mySQL

Download @ http://mysql.hjc.edu.sg/downloads/index.html (Singapore Mirror)

I’ll be downloading:

Windows 95/98/NT/2000/XP 4.0.12 20.9M

1.3 PHP

Download @ http://php.hjc.edu.sg/downloads.php

I’ll be downloading “PHP 4.3.1 installer [1,028Kb] – 17 February 2003”

Now that we have all the stuffs downloaded, it’s time to do the installation! To recap, I have:

1. Apache (apache_2.0.44-win32-x86-no_ssl.msi)
2. mySQL (mysql-4.0.12-win.zip)
3. PHP (php-4.3.1-installer.exe)

2.0 Apache

It’s quite easy, double click the .msi file and the installation will run you through.


Double click me!


Click Next…


Accept the terms…


Click Next…


The defaults should work just fine…


Typical setting please…


Default installation folder…


Click Install to install…


Installing…


Done!

Now open your browser and type in http://localhost or http://127.0.0.1 you should see the following:

Apache is setup and running. You ill notice that there is also now a little utility sitting on your task bar tray


circled in white

This is a easy way to see the running Apache service, restart it, stop it or start it.


The Apache Service Monitor

3.0 PHP

Just install PHP like you would with any other software:


Standard is fine…


Default dir to install to is good…


Remember to select Apache.


oops, don’t worry…click ok.


Done!

3.1 Testing PHP is working in Apache

First of all, you will need to edit your httpd.conf file to let it load php files when they appear, as in if you have a index.php file in http://localhost/phptest/, php.index should load when you type that URL and not list the directory’s file.

Go to Start > All Programs > Apache HTTP Server 2.0.44 > Configure Apache Server > Edit the Apache httpd.conf configuration file

We simply need to add in index.php (as highlighted below) into the “DirectoryIndex” directive. You may wanna use the search function to look for directoryindex or else you’ll be scrolling none stop…

For more information read:

From Bignosebird.com > “I need to use something other than index.html as the default page for my site. I was thinking of using either index.cgi or index.shtml. If I remove index.html, all I see is a directory listing! What’s the fix? Changing the DirectoryIndex.”

Process my .php

Next you need to add tell Apache to process PHP files with the correct stuffs, or else it will just ask if you wanna download everything that is .php . According to the PHP documentation (located @ http://www.php.net/manual/en/install.apache2.php):

You need to insert these three lines to your Apache httpd.conf configuration file to set up the CGI binary:

Example 3-7. PHP and Apache 2.0 as CGI

ScriptAlias /php/ "c:/php/"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php/php.exe"

So, ok, I’ll just copy and paste those into httpd.conf again. Search for scriptalias in your httpd.conf file and add them in (as hightlighted below):


Remember to save the file after adding those 3 lines in…

PHPInfo.php to test

What better way to test php is working in Apache, or not than to try running phpinfo.php, as usual, Click to download- phpinfo.zip

Unzip that file into C:program Filesapache GroupApache2htdocs which is the default directory that stores your web server files. After placing phpinfo.php into that directory, go back to your browser and type in http://localhost/phpinfo.php

You should see:


PHP now works!

4.0 mySQL

Same thing, install mySQL as you would install any software in Windows.

Click Finish to finish the mySQl installation program. It’s done!

Testing if mySQL is running

Start the GUI mySQLadmin by double clicking on C:mysqlbinwinmysqladmin.exe

Now you’ll see another utility running on the tray that looks like a traffic light with green lights on:

Now start MS Dos, go to Start > Run and type in cmd and hit Enter

Navigate to C:mysqlbin then type in mysql

See the prompt is change to mysql >

And waiting for your command. If it shows that, it means mysql is running.

All running now

Now Apache with php and mySQL is all running, we will try installing phpBB to test out the whole thing. You may wanna refer to this to see how to install phpBB on a web server but the following will show you how to install phpBB in a local Intranet environment.

I will first of all delete all the files in C:program Filesapache GroupApache2htdocs as I won’t need those files anymore. I’ll leave phpinfo.php for future references.

phpBB installation

Obtain phpBB installation files @ http://www.phpbb.com I’ll be using:

phpBB 2.0.4 [ Full Package ]

After downloading that zip file, unzip all files to C:program Filesapache GroupApache2htdocs, a new folder named phpBB2 will be created automatically for you.

Create mySQL Database

You will then need to create a mySQL database to hold all data of this new forum you’re going to have. I would suggest installation of phpMyAdmin to do this much easily but of course, you can create the mySQL database manually. I’ll be doing it via phpMyAdmin.

Obtain phpmyadmin @ http://phpmyadmin.sf.net I’ll be downloading phpMyAdmin-2.4.0-php.zip

Unzip all files to C:program Filesapache GroupApache2htdocs, a new folder named phpMyAdmin-2.4.0 will be created automatically for you. I change that folder name to plainly phpmyadmin so as I can just access it via http://localhost/phpmyadmin

Go to C:program Filesapache GroupApache2htdocsphpmyadmin and look for a file named “config.inc.php”. Then search PmaAbsoluteUri and set it to the full path to phpmyadmin. (note that this is an Intranet forum)


See highlighted. remember to save the file when done!

Now go that http://localhost/phpmyadmin and you’ll see:

Creating Password for root

Note the word in red:

Your configuration file contains settings (root with no password) that correspond to the default MySQL privileged account. Your MySQL server is running with this default, is open to intrusion, and you really should fix this security hole.

ok, we just need to create a password for user root then.

Click on Privileges


Key in the password twice then click Go.

Now when you try to access phpmyadmin’s main page again, you will get an error:

Welcome to phpMyAdmin 2.4.0

Error

MySQL said:

Access denied for user: 'root@127.0.0.1' (Using password: NO)

So you need to tell phpMyAdmin your password then you can use it now.

Open C:program Filesapache GroupApache2htdocsphpmyadminconfig.inc.php (again) and look for $cfg[‘Servers’][$i][‘password’] enter the password you have set earlier there. See circled in red below:


Save your file when done.

Now reload phpmyadmin at http://localhost/phpyadmin/ And you’ll see that main page of phpmyadmin again!

Remember that the above only happens when we did the installation of phpMyAdmin from scratch. On normal production servers, most of the time, it is configured beforehand.

Creating the database “forum”

I’ll create a new database named simply forum which will hold the data of my new phpBB forum.


Type in the database (forum in my case) and click Create. That’s it!

Installing phpBB

Go to http://localhost/phpBB2/ now and you should be redirected to http://localhost/phpBB2/install/install.php

Fill in everything, again, refer to this on how to configure the above. Mine is as follows:


Click Start Install when done.


Done!


Delete the install and contrib folders…


And we’re done!

Refer to this on how to backup your forum via phpMyAdmin

Links:

Apache
Internet Information Server
Windows 2000
Linux
mySQL
PHP
http://www.phpbb.com
http://www.hjc.edu.sg/ < They are one great site for Singapore mirrors to Open Source Stuffs such as php, mySQL, Redhat and Mandrake
http://www.bignosebird.com / APACHE Server Tricks
– Contributed by etegration
28 March 2003

Pages

Sidebar Block

* Function Not Configured *

Archives