Windows XP, Apache 2.2 - where to put php file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ManUtdFans
Forum Newbie
Posts: 7
Joined: Tue Jan 19, 2010 8:22 pm

Windows XP, Apache 2.2 - where to put php file

Post by ManUtdFans »

Install Apache 2.2 (use port 8080) on Windows XP(also IIS), and installed PHP 5.

To get started to learn PHP, where should I put the PHP 5 (test.php) under Apache?
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Windows XP, Apache 2.2 - where to put php file

Post by McInfo »

Find the configuration file for Apache Server. It's named httpd.conf and is probably located in a folder like "C:\apache\conf\". Open the file and search for "DocumentRoot". The document root is where you should put your PHP files.

PHP Manual

Edit: This post was recovered from search engine cache.
Last edited by McInfo on Thu Jun 17, 2010 4:39 pm, edited 1 time in total.
ManUtdFans
Forum Newbie
Posts: 7
Joined: Tue Jan 19, 2010 8:22 pm

Re: Windows XP, Apache 2.2 - where to put php file

Post by ManUtdFans »

McInfo wrote:Find the configuration file for Apache Server. It's named httpd.conf and is probably located in a folder like "C:\apache\conf\". Open the file and search for "DocumentRoot". The document root is where you should put your PHP files.

PHP Manual
Yes, I found the similar location.
As I am pretty new to php and apache, how do I start the apache?

I dont' find an item in the Apache program group has this item.

I tried to create a bat file has contents:

c:
cd "c:\program files\apache software foundation\apache 2.2\bin"
httpd.exe

But I got the error box from Windows:
"The program cannot start because ntwdblib.dll is missing from your computer."

I think it worked before.

Any idea?
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Windows XP, Apache 2.2 - where to put php file

Post by McInfo »

A package like XAMPP might better suit your needs. It includes Apache, PHP, MySQL, and a few other things. It has a control panel so you can easily stop and start the server.

With the installation you have, there may be an Apache Monitor icon in the System Tray that you can use to control the server. (More)

If you don't see the Apache Monitor icon, you can control the server from the command line with httpd.exe. (Instructions)

To check if the server is running, go to http://localhost/ or http://127.0.0.1/.

Edit: This post was recovered from search engine cache.
Last edited by McInfo on Thu Jun 17, 2010 4:40 pm, edited 1 time in total.
ManUtdFans
Forum Newbie
Posts: 7
Joined: Tue Jan 19, 2010 8:22 pm

Re: Windows XP, Apache 2.2 - where to put php file

Post by ManUtdFans »

McInfo wrote:A package like XAMPP might better suit your needs. It includes Apache, PHP, MySQL, and a few other things. It has a control panel so you can easily stop and start the server.

With the installation you have, there may be an Apache Monitor icon in the System Tray that you can use to control the server. (More)
I have installed successfully.
I created a php file with simple html and php code and saved under
c:\xampp\apache\htdocs\test.php

I check the httpd.conf the DocumentRoot is correct:
c:\xampp\htdocs

When I tried to open the URL with FireFox:
http://localhost:8080/test.php

The FireFox cannot connect to this URL.

The apache is running showed in the monitor.

However, I checked with xampp control monitor the port_check, the HTTP Apache is using 80, so I changed the listen port in httpd.conf to 8080.

But it still does not work.
In addition, the control monitor shows TomCat is using 8080.
Why there is TomCat installed?
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Windows XP, Apache 2.2 - where to put php file

Post by McInfo »

XAMPP is a package. It is an alternative to installing Apache and PHP separately. If you use XAMPP, you don't need the Apache or PHP that you installed before. You also don't need IIS.

Did you change the port because IIS is listening on port 80? If you don't run IIS and Apache at the same time, they can both be assigned to port 80 without conflict.

XAMPP's optional Tomcat addon allows you to run Java on Apache Server. If the "Start" button for Tomcat is disabled in the XAMPP Control Panel, the addon is not installed, so it is not actually using port 8080. If that is the case, there should be no conflict with Apache listening on port 8080.

Remember to always restart Apache after making changes to httpd.conf or php.ini. The configurations are loaded at startup and changing the files does not change the values stored in memory.

Edit: This post was recovered from search engine cache.
Last edited by McInfo on Thu Jun 17, 2010 4:40 pm, edited 1 time in total.
ManUtdFans
Forum Newbie
Posts: 7
Joined: Tue Jan 19, 2010 8:22 pm

Re: Windows XP, Apache 2.2 - where to put php file

Post by ManUtdFans »

It looks like I did not change the port listenen by Apache correctly.

Today I turned on my PC and checked with xampp's control panel and 'Port-Check'.
It shows the Port is still 80.

I opened the httpd.conf and the entries:
#Listen 0.0.0.0:80
#Listen [::]:80
Listen 8080

ServerName localhost:8080

It looks like Apache does not pick up from httpd.conf
ManUtdFans
Forum Newbie
Posts: 7
Joined: Tue Jan 19, 2010 8:22 pm

Re: Windows XP, Apache 2.2 - where to put php file

Post by ManUtdFans »

I stopped the IIS.
Open browser, type in

http://localhost:8080/test.php

It works.

I quite don't understand.

http://localhost:8080/test.php
means Apache using the port 8080, right?

So it should also be working even when IIS is running because they use differenct port.
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Windows XP, Apache 2.2 - where to put php file

Post by McInfo »

I did a test on my computer. I set XAMPP's Apache to listen on port 8080 and IIS to listen on port 80. They worked as expected, Apache from http://localhost:8080/ and IIS from both http://localhost:80/ and http://localhost/. I did notice, however, that XAMPP's "Port-Check" feature still reported that Apache was on port 80. I'm not sure how it determines that. It's probably safe to just ignore it.

Are you saying that you can access Apache only when IIS is stopped? Can you describe again what the problem is?

See if there is anything in the hosts file ("C:\Windows\System32\drivers\hosts").

Confirm that your IIS site is bound to port 80. (How?)

Edit: This post was recovered from search engine cache.
Last edited by McInfo on Thu Jun 17, 2010 4:43 pm, edited 2 times in total.
ManUtdFans
Forum Newbie
Posts: 7
Joined: Tue Jan 19, 2010 8:22 pm

Re: Windows XP, Apache 2.2 - where to put php file

Post by ManUtdFans »

Hi,

I know what's happening:
#Listen 0.0.0.0:80
#Listen [::]:80
Listen 8080

I modified as:
#Listen 0.0.0.0:8080
#Listen [::]:8080
Listen 8080

Now everything works fine.

But it makes me curious that the '#' is a comment sign, isn't it?
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Windows XP, Apache 2.2 - where to put php file

Post by McInfo »

ManUtdFans wrote:'#' is a comment sign, isn't it?
It's supposed to be.

That's strange. Maybe try changing it back to confirm that that is actually what fixed your problem.

Edit: This post was recovered from search engine cache.
Last edited by McInfo on Thu Jun 17, 2010 4:41 pm, edited 1 time in total.
ManUtdFans
Forum Newbie
Posts: 7
Joined: Tue Jan 19, 2010 8:22 pm

Re: Windows XP, Apache 2.2 - where to put php file

Post by ManUtdFans »

McInfo wrote:
ManUtdFans wrote:'#' is a comment sign, isn't it?
It's supposed to be.

That's strange. Maybe try changing it back to confirm that that is actually what fixed your problem.
It's strange.
I revoked back to:
#Listen 0.0.0.0:80
#Listen [::]:80
Listen 8080

It still is working.
Not sure what I did to make it work.
Post Reply