I am absolutely no experience in Apache -- well, no first hand experience, that is. Where do I start, where do I download? What do I download?

I have been trying to get serious about developing my web site. I have Windows XP Home Edition OS and I have not yet been able to get going. [img]http://fool.exler.ru/sm/kngt.gif[/img] Do really need to explain my conclusion why I need to get Apache? In order to do Source Save, I need IIS. In order to use IIS, I cannot have Windows XP Home, I need to either get free Apache or buy Windows XP Pro.

So, where do I start? What is a good plcae to get it and what is a good place to get information?

I have downloaded Apache for the Windows operating system and have read the installation documentation and I have a question: Do I need to register a domain name before I install Apache?

I am getting Apache, by the way, so that I can:

  1. Edit and debug PHP without having to upload to a sever constantly.
  2. I can use Source Safe on my home computer. This is a somewhat long story. But, basically, Source Safe requires either IIS or Apache and IIS does not exist for Windows XP Home Edition.

Anyway, in the installation documentation for Apache, it reads:

Run the Apache .msi file you downloaded above. The installation will ask you for these things:

  1. Network Domain. Enter the DNS domain in which your server is or will be registered in. For example, if your server's full DNS name is server.mydomain.net, you would type mydomain.net here.

Do I need to register a domain name before I install Apache?

No, you can put anything in there if you are only going to use it locally

Edit and debug PHP without having to upload to a sever constantly.

Quick tip: I use PSPad as my code editor. Like many advanced editors, it includes the ability to edit files directly on your webserver using ftp. So you "open" files from your ftp server. When you save, it saves by ftping the changed file to your server. No more saving locally, then manually ftp'ing to your server. This saves a lot of time for me. PSPad is free and high quality. You can also integrate the PHP documentation file so you can hover over any PHP statement and hit Alt-F1 to see the PHP documentation--very handy.
www.pspad.com

Tutorial to setup WAMP on Windows XP Home or Pro

  1. Apache v2
  2. PHP v5
  3. MySql v4.1
  4. phpMyAdmin

Personally, I do my webdev on Linux, but needed to figure this out for a Windows XP Home user. I found it very easy to setup, but only because I have a lot of experience with these products. For a newbie, I can imagine this process would be very confusing. So as of today, 7/4/2005, these are good instructions to follow step-by-step to get this working. In this tutorial, I do not attempt to tell you HOW to use Apache, MySql, PHP, or phpMyAdmin. Instead, I explain only enough to get it all downloaded, installed, configured, and tested.


As fast as things change, these instructions may not be accurate in 30 days, but here goes...PLEASE follow these directions in the order listed.

---------------------------------------------------------------
Apache
- The Web Server
---------------------------------------------------------------

I am not providing a direct link to a download since the links can change often, and Apache prefers you use a "local" mirror site to download from. So visit http://httpd.apache.org/download.cgi and download the "Win32 Binary (MSI Installer)". The actual file name at time of this writing is apache_2.0.54-win32-x86-no_ssl.msi.

Run the installer and follow the installation wizard using all the default options. When asked to provide a domain name, if you are just installing for personal local development and learning, you can enter anything you want. Try mydomain.net for example. This same screen will prompt for a server name and an email address. The server name must include the domain name. So you could enter www.mydomain.net . (In this case, the name of your computer is "www" and the full name is "www.mydomain.net". It does not have to match the actual computer name of your machine.) You can just enter your real email address--it wont matter.

If everything worked, you should now have Apache installed and configured as a Windows Service which means it will automatically start when you start Windows. You should have a new icon in your System Tray that is a little red Apache feather. The icon shows the status of your web server--green for running and red for stopped. You can click it to open the Apache Service Monitor. You use this to Stop, Start, and Restart the service. You will need to restart the service anytime you make a configuration change---more on that later.

Confirm that the service is running. If not, start it. If it fails, then your problems are beyond this tutorial. Sorry. Thank you for playing. There is no need for you to continue beyond this point.

Congratulations! You have a web server! Open a browser and go to http://localhost . You should see the Apache default page telling you your server is working. These pages are being served from the DocumentRoot, which by default is a folder named htdocs within the location you installed Apache. Default is C:\Program Files\Apache Group\Apache2\htdocs. I like to leave this folder alone, and create my own DocumentRoot to build my website in. To do this, create a folder named www on your C:\ drive. Navigate to your C:\www folder, and create a new file using Notepad or your favorite text editor. (I recommend PSPad .) Name it index.html. Copy and paste the following into c:\www\index.html.

<html>
<head>
<title>My Own Local Web Server</title>
</head>
<body>
<h1>Hello, World!</h1>
</body>
</html>

Now we need to edit the Apache configuration to point it to our c:\www folder as the DocumentRoot. To do this, again in your favorite text editor, open the Apache conf file. By default this is C:\Program Files\Apache Group\Apache2\conf\httpd.conf. Find the line that looks like this:

DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs"

And turn it into this:

DocumentRoot "C:/www"

Save your changes. Using the Apache Service Monitor, Restart the service. Open a browser and go to http://localhost . You should see your new home page which is c:\www\index.html.

Whew! Step 1 complete.

---------------------------------------------------------------
PHP
- The Scripting Language
---------------------------------------------------------------
Visit http://www.php.net/downloads.php and download "PHP 5.0.4 zip package". The actual file name at time of writing was php-5.0.4-Win32.zip.

Create a folder named php on your C:\ drive. Unzip the file into c:\php.


Make a copy of c:\php\php.ini-recommended and name it c:\php\php.ini


Right-click My Computer and choose Properties. Choose the Advanced tab. Click the Environment Variables button at the bottom. In the System Variables section, click Path, then the Edit button. At the end of the path value, add ;C:\php;C:\php\ext Click OK and keep clicking OK until you exit out of the Properties. Reboot your computer. Grab a drink. Don't worry, I'll wait for you here.

Welcome back. Now we have to modify the Apache conf so it knows to use the PHP module. To do this, again in your favorite text editor, open the Apache conf file. Find the LoadModule section that begins with a comment line that looks like this:

# Dynamic Shared Object (DSO) Support

At the end of the list of LoadModule lines, add these 4 lines:

# PHP5
LoadModule php5_module "c:/php/php5apache2.dll"
AddType application/x-httpd-php .php
PHPIniDir "c:/php/"

Also, find this line:

DirectoryIndex index.html index.html.var

And change it to this:

DirectoryIndex index.html index.html.var index.php

Now, save your changes, and restart Apache. (By now, you should know how to restart Apache.)

Create a new file named c:\www\index.php. Copy these lines into it:

<?php
phpinfo();
?>

Save this file. Rename c:\www\index.html to c:\www\old_index.html.

Open http://localhost in your browser. You should see the phpinfo page that displays your PHP version at top and a lot of system and user information tables. (Check out the phpinfo() function at http://www.php.net/manual/en/function.phpinfo.php )

If this did not work for you, your issues are beyond the help of this tutorial. Sorry. Thank you for playing. There is no need to continue beyond this point.

Congratulations! You not only have a web server, you have successfully incorporated the PHP scripting module into Apache.

---------------------------------------------------------------
MySql
- The Database
---------------------------------------------------------------
Visit http://dev.mysql.com/get/Downloads/MySQL-4.1/mysql-essential-4.1.12a-win32.msi/from/pick#mirrors to download the MySql 4.1 Windows Essential (x86) package. The actual filename at time of writing was mysql-essential-4.1.12a-win32.msi.

Run the installer and use all the default values. When prompted for a root password, choose one you can remember. Normally, security is an issue here, but if this is just for you to learn and play, it does not matter much.

Once the installation is complete, MySql should be configured as a Windows Service which means it will auto start when you start Windows. You should have a new MySql folder in your Start/All Programs menu. One of the items in the menu is MySQL Command Line Client. You can use this to do all your database administration from creating databases and tables to inserting data, etc. However, most people are not very comfortable using the command line interface, so later, I'll show you how to setup phpMyAdmin--a browser-based GUI tool. For now, though, use the MySQL Command Line Client to test your installation. Open the command line client to see a password prompt. Enter your root password. If successful, you'll see something like this:

Welcome to the MySQL monitor. Commands end with ; or \g. 
Your MySQL connection id is 60 to server version: 4.1.12a-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

If this does not work for you, your issues are beyond this tutorial. Sorry. Thank you for playing. There is no need to continue beyond this point.

Congratulations! You now have a working MySql database server.

Now you need to configure PHP to work with MySql. Open c:\php\php.ini in your favorite text editor. There are 2 lines you need to uncomment. Change this line:

;extension=php_mbstring.dll

To:

extension=php_mbstring.dll

Change this line:

;extension=php_mysql.dll

To:

extension=php_mysql.dll

Save your changes. Restart the Apache service. (That's right--since we are using php as an Apache module, anytime you change either the Apache conf file or the PHP ini file, you must restart Apache to see your changes.)


To test that you have PHP configured to work with MySql, create a file named c:\www\dbtest.php. Copy and paste the following into it:

<?php

$db_server = "localhost";
$db_user = "root";
$db_pwd = ""; //Enter your root password here.
$db_db = "mysql";

if (!$cnn = mysql_connect($db_server, $db_user, $db_pwd)) {
  echo mysql_error();
  exit();
}
if (!mysql_select_db($db_db, $cnn)) {
  echo mysql_error();
  exit();
}

$sql = "select * from help_category";
if (!$res = mysql_query($sql, $cnn)) {
  echo mysql_error();
  exit();
}
while ($row = mysql_fetch_array($res, MYSQL_ASSOC)) {
  $data[] = $row;
}


?>
<html>
<head>
<title>Apache/PHP/MySql Test</title>
</head>
<body>
<h1>Help Categories</h1>

<?

echo "<style>table.dump { font-family:Arial; font-size:8pt; }</style>";
echo "<table class=\"dump\" border=\"1\" cellpadding=\"1\" cellspacing=\"0\">\n";
echo "<tr>";
echo "<th>#</th>";
foreach($data[0] as $key=>$val) {
  echo "<th><b>";
  echo $key;
  echo "</b></th>";
}
echo "</tr>\n";
$row_cnt = 0;
foreach($data as $row) {
  $row_cnt++;
  echo "<tr align='center'>";
  echo "<td>".$row_cnt."</td>";
  foreach($row as $val) {
	echo "<td>";
	echo $val;
	echo "</td>";
  }
  echo"</tr>\n";
}
echo "</table>\n";

?>

</body>
</html>

Be sure to put your mysql root password in the 5th line. Save your changes. Open http://localhost/dbtest.php in your browser. You should see the contents of the help_category table in the default "mysql" database.

---------------------------------------------------------------
phpMyAdmin
- Browser-based GUI Admin tool for MySql
---------------------------------------------------------------
Download the latest stable release of phpMyAdmin. You can find this by starting at http://www.phpmyadmin.net/home_page/index.php . At time of this writing, the latest stable release was 2.6.3. When I clicked to download it, though, I ended up with v2.6.2. No problem--it works. I got it at http://prdownloads.sourceforge.net/phpmyadmin/phpMyAdmin-2.6.3.zip?download
The actual filename at time of writing was phpMyAdmin-2.6.2-pl1.zip.


Create a folder named c:\www\phpMyAdmin. Unzip the file into this new folder. Open C:\www\phpMyAdmin\config.inc.php in your favorite text editor. Find this section, and input your mysql username and password. You should enter 'root' as the username, and the root password you used when you installed MySql.

$cfg['Servers'][$i]['user']		 = '';	 // MySQL user
$cfg['Servers'][$i]['password']	 = '';		 // MySQL password (only needed

Be careful as there are other places in the config file that look like places to put your username and password. Find the lines that look exactly like what I listed above--and only change those 2 lines.


Save your changes. Open http://localhost/phpMyAdmin in your browser. If you do not see the phpMyAdmin tool, then your issues are beyond this tutorial. Sorry. Thank you for playing. There is no need to continue beyond this point.


Congratulations! You now have a WAMP system with phpMyAdmin to administrate your database. Enjoy the journey.

kind of an aside i know but I jsut upgraded to the most recent (stable) version of phpMyAdmin and so far I am very impressed with the new interface changes, very slick.

Wow.

Hey, I downloaded and am running XAMPP along with Apache.

Is that going to mess things up?

Otherwise, tell me did it work so far?

Can anyone access http://192.168.0.100/ from the outside world?

Bill, 192.168.0.100 is a private IP address. Nobody will be able to access it from the Internet. Any addresses in these ranges are private:

10.0.0.0 - 10.255.255.255
172.16.0.0 - 172.31.255.255
192.168.0.0 - 192.168.255.255

These are designed to be used in local networks that access the Internet behind a router or firewall. (Or networks that are not even connected to the Internet. Yes, there actually are networks NOT connected to the Internet! GASP!) More info at http://www.jpsdomain.org/networking/nat.html

My guess is you are using a Linksys Cable/DSL Router. I say this, because they default to using the 192.168.0.0 network, and the first DHCP address they give out by default is 192.168.0.100.

For people on the Internet to access your webserver, there are two things you have to do.

First, you must find out what your public IP address is. This will be the IP address of your router's external port--the address assigned by your ISP. You can find your external IP by checking your router's config. You can access your router's admin page at http://192.168.0.1. You can also simply go to http://www.whatismyip.com/ to see what your external IP is.

Second, you must configure your router to allow web traffic (TCP, port 80) to your local 192.168.0.100 computer. To do this, you need to go to your router's admin page and find the section where you configure port forwarding or NAT.

As for messing things up with XAMPP, it's not going to mess anything up, but you said "..along with Apache". It appears XAMPP includes Apache, so you would not install XAMPP along with Apache. You'd just install XAMPP. XAMPP gives you more than my HOWTO, but it doesn't look any easier to follow than my simple step-by-step instructions. I'm curious, did my detailed instructions not work for you, so you went and found XAMPP? Or did you find XAMPP before looking at my post above?

Hi there,

I am having a similar problem.

I would like to access my apache server from my external IP address but cannot access the page.

It works fine from http://localhost

I have forwarded both inbound and outbound ports to my
[Internal] ip address 192.168.0.2 for port 80 via my router
but still cant access...

Got this working before and i was nearly sure i had to edit the httpd.conf file in apache??

Any help is much appreciated...

You are a life saver...HOw can I ever thank you for helping me setup php/mysql/admin/apache. thank to your instructions I was able to successfully setup my system for web development.

i could not find the line
"DirectoryIndex index.html index.html.var"

All, I just wanted to pop in here to say first, thanks for the thanks and glad I could help. Second, those very specific steps I provided were back in 2005, as indicated in the post. Some things are bound to change. I do not have time to revamp the instructions for current versions, but I can tell you that not a lot has changed. It will require you, though, to do some translating--which may not be possible for a beginner. My apologies!

Please do not PM me for personal help as I simply do not have the time these days. Hopefully one of you will find a better, more up-to-date tutorial and post a link here.

Stick with it--it gets easier! :)

@Troy, Thanks for the information!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.