Apache server will not interpret PHP file for browser

Hi Forum,

My name is Tom and I am a new user of Apache HTTP, PHP, and MySQL. I downloaded the software from the XAMPP – Bitnami site a few days ago and installed in on my PC. My PC is running Windows 7 Home Premium.

I am working through the book by Kevin Yank entitled “PHP & MySQL, Novice to Ninja”. I got as far as installing the software and running the XAMPP Control Panel and starting Apache and MySQL.

I then downloaded from the the book’s online site at Sitepoint the PHP module for chapter 1, “Today.php”, and put it into the folder at c:/xampp/htdocs on my PC.

I then went to my browser ann typed in http://localhost/today.php

Instead of getting the interpreted code as shown in Yank’s book, I got a view of the php code in today.php. Yank says that the server is supposed to interpret the code for the browser, but the browser just displayed the uninterpreted code.

Something must be wrong with my set up. Can anyone suggest what it might be?

thanks,

Tom

Yes, something is wrong.

Normally, when that happens is because Apache doesn’t know that PHP exists. Inside Apache’s configuration file there should be a few lines that tells Apache that anything with PHP extension should be interepreted by PHP and the result served by Apache.

Open your Apache httpd.conf file and do a search for “PHP”. If it does come with some result, then post it here so we can see if the configuration is right.

If you find nothing, then you’ll have to add them yourself. Let us know so we can give you the appropiate indication (although a search in Google will help you too, this is a common problem)

When I search the file: c/xampp/apache/conf/httpd.conf for “PHP” I find this section in the file:

<IfModule dir_module>
DirectoryIndex index.php index.pl index.cgi index.asp index.shtml index.html index.htm \
default.php default.pl default.cgi default.asp default.shtml default.html default.htm \
home.php home.pl home.cgi home.asp home.shtml home.html home.htm
</IfModule>

Thanks,

Tom Schlehuber

That’s fine but with those lines you simply are telling the server the possible names for the first page of the website and in which other needs to look for them

That is: “first, when someone keys www.dom.com, search for index.php but if you don’t find it, try to find index.pl and it that one isn’t there, then try index.cgi and so on…”

I was looking for something similar to


LoadModule php5_module "c:/php5/php5apache2_4.dll"
AddHandler application/x-httpd-php .php
PHPIniDir "c:/php5"

Where you’re loading the PHP module (which will be the one to do the processing, telling Aphache that php extensions will be handled by this module, and where is the php.ini file

In my case, I installed PHP under a folder names PHP5

There is nothing like the code you indicated in my httpd.conf file. The only references to PHP were the ones I gave you.

So are you suggesting that I go into the httpd.conf file and insert the code you gave me? If so, I guess I would need to move my c:/xampp/php folder to c:/php5. Can I just use any text editor such as notebook to do the edits, and can I just do a move of the folder or does it need to be installed in a different location?

Please advise and thank you.

Tom

Yes. But you don’t need to change or move your php folder… simply change the paths in the lines I wrote to the appropriate one :slight_smile:

Ok, I loaded the code you suggested into the httpd.conf file.

The code I loaded was:

#LoadModule php5_module “c:/php5/php5apache2_4.dll”
#AddHandler application/x-httpd-php .php
#PHPIniDir “c:/php5”

LoadModule php_module “c:xampp/php/phpapache2_4.dll”
AddHandler application/x-httpd-php .php
PHPIniDir “c:/xampp/php”

Now I cannot start the Apache module from the XAMPP Control Panel. I checked the error logs and do not see any errors with today’s date on them. Then I went to the Windows Event Viewer and found an error called: this error: Windows Operating System, Microsoft-Windows-Security-SPP, 903.

When I looked up this error message under MS, I got this: – something about “No Key Servers Found”

Results 1-20 of about 410 for: Windows Operating System, Microsoft-Windows-Security-SPP, 903
Forums
Answered Question
Windows Authentication fails with No Key Servers Found‎
Windows 7 Installation, … Microsoft Product: Windows Operating System; Version: 6.1.7600.16385; Event ID: 8196; Event Source: Microsoft-Windows-Security-SPP; …

If I comment out the 3 lines of new code, the Apache module loads OK.

Any ideas of what is wrong?

thanks,

Tom

Hmmm… You wrote

LoadModule php_module "c:/x[COLOR=#333333]ampp/php/phpapache2_4.dll"

Is this really how you wrote it? Or is it simply that you wrote a typo when you posted this?

I mean because it is LoadModule php5_module

Notice the 5? ;)[/COLOR]

Ok, I entered the “5” into the LoadModule command just after “php”

However, the Apache module still will not load from the XAMPP Control Panel. There is nothing in the Apache or PHP error logs with today’s date on them.

I checked the MS Windows Event Viewer Logs and under Windows Logs: Security I found 2 entries with today’s date, but the time stamp was about 30 seconds before I tried to load the module (I might have the seconds wrong). These entries reported Event IDs of 4905 and 4904, and they both had the following event descriptions:

An attempt was made to unregister a security event source.

Subject
Security ID: SYSTEM
Account Name: TGS–LAPTOP$
Account Domain: HOMEGROUP
Logon ID: 0x3e7

Process:
Process ID: 0x390
Process Name: C:\Windows\System32\VSSVC.exe

Event Source:
Source Name: VSSAudit
Event Source ID: 0xaed396

Any ideas on why I am continuing to have problems loading the Apache module?

thanks,

Tom

It may have something to do with the ports :scratch:

Still, you’re not going to see anything in Windows Even viewer unless there’s some kind of issue with the firewall, or UAC or something similar (which is another possibility)

All errors will be in the Apache’s error log. That’s what you need to check

And if Apache can’t run because you added those lines, definately there’s got to be something in the error log.

If it simply doesn’t start from the XAMP window but it does start when you ask you (using another method), then the problem is not Apache

The code I inserted into the c:/xampp/apache/conf/httpd.php file was:

LoadModule php5_module “c:/xampp/php/php5apache2_4.dll”
AddHandler application/x-httpd-php .php
PHPIniDir “c:/xampp/php”

When I try to Start Apache from the XAMPP Control panel, the panel gives me a series of messages to the effect that Apache could not load, namely:

Error: Apache shutdown unexpectedly.
2:37:56 PM [Apache] This may be due to a blocked port, missing dependencies,
2:37:56 PM [Apache] improper privileges, a crash, or a shutdown by another method.
2:37:56 PM [Apache] Press the Logs button to view error logs and check
2:37:56 PM [Apache] the Windows Event Viewer for more clues
2:37:56 PM [Apache] If you need more help, copy and post this
2:37:56 PM [Apache] entire log window on the forums

The Apache error log for today shows the following:

[Wed Nov 06 14:37:22.724084 2013] [mpm_winnt:notice] [pid 2500:tid 368] AH00422: Parent: Received shutdown signal – Shutting down the server.
[Wed Nov 06 14:37:24.729199 2013] [mpm_winnt:notice] [pid 3024:tid 260] AH00364: Child: All worker threads have exited.
[Wed Nov 06 14:37:24.939211 2013] [mpm_winnt:notice] [pid 2500:tid 368] AH00430: Parent: Child process 3024 exited successfully.

Hopefully this shows what the problem is.

thanks,

Tom

P.S.

I may not have mentioned before that I am running Win 7 Home Premium edition, SP1 on a 64 bit Operating System.

Also, I recently experimented with running or setting up Apache to run as a service. Should I shut that off?

thanks,

Tom

Why didn’t you start there? If the service is running and unless you specified the port for each one of those installations, yes, it is a problem

You can’t have two web servers (be it two Apache installations, or Apache and IIS or ISS and any other) listening to the same port. They would compete against each other.

Now, if these installations are listening to different ports then you shouldn’t have a problem at all.

Apache should be running as a service but since I never installed XAMP (I always did manual installations of each one of these components) I don’t know if XAMP itself uses its own service for everything.

The one thing that you should check (which is actually what your log says) is Windows Even Viewer for that date and time.

Molona,

Sorry, but I’m such a novice I don’t understand some of what you’re telling me.

If I am running the Apache as a service, then when I try to start Apache it hangs with the message “Attempting to start Apache app.” in the XAMPP Control Panel.

If I turn the Apache service off, then when I try to start Apache it bombs out with the message reported in my last message to you.

The Windows event viewer shows this:

  • System

    • Provider

    [ Name] Apache Service

    • EventID 3299

    [ Qualifiers] 0

    Level 2

    Task 0

    Keywords 0x80000000000000

    • TimeCreated

    [ SystemTime] 2013-11-06T23:24:23.000000000Z

    EventRecordID 135870

    Channel Application

    Computer TGS–Laptop

    Security

  • EventData

    The Apache service named

    reported the following error: >>>
    Only first PHPINIDir directive honored per configuration tree - subsequent ones ignored

Unless you see something fairly obvious here, I’m wondering if there might not be a better way to figure this out. Would you or someone knowledgeable be willing to log into my system remotely and take a look at the setup, say using Teamviewer or JoinMe or the like. I have Teamviewer installed on my PC.

OR, alternatively, I could just uninstall what I have and start over; in which case can you send me instructions for how to do the kind of manual installation of each one of the components that you said you had used.

Which would be a better way to proceed?

thanks,

Tom

Have you got Skype running at the same time? It’s a common culprit for using port 80, try setting Skype to use a different port or make sure Skype is quit before starting up the XAMP server.

SpacePhoenix,

I do have Skype installed on my PC, but it is not running and hasn’t been for months. How do you set an application to use a different port?

thanks,

Tom

You need to change it in the httpd.conf file you should have something that read like this


# Change this to Listen on specific IP addresses as shown below to 
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80

What goes after the “listen” command is the port you want to use. It is 80 by default but you can change it to 8080 or to 123

Do remember that to test it you will not be able to type “localhost” in your browser. You’ll type [noparse]“localhost:portNbr”[/noparse]

Edit: I know it is hard to tell but when I wrote “Why didn’t you start there?” I was joking :slight_smile:

We’ve all been there, we all start from zero and, as you can see, it is still hard to figure out when a problem arises :smiley:

So don’t worry. You’re a newbie now but you will not be in the future :slight_smile:

Molona,

Thanks for the encouragement.

However, I can’t test the port because I can’t get that far when the Apache module isn’t even loading.

Again, the code I inserted that keeps it from loading is the code you previously gave me, namely:

LoadModule php5_module “c:/xampp/php/php5apache2_4.dll”
AddHandler application/x-httpd-php .php
PHPIniDir “c:/xampp/php”

If I comment these lines of code out, the Apache module loads just fine, and the XAMPP Control Panel reports that the Apache is using ports 80 and 443. Since it’s using port 80 OK, I don’t think there is a conflict with Skype or any other application that might also be trying to use port 80.

But then the localhost/today.php command in my browser isn’t interpreting the php code for the browser and the browser just displays the file contents showing the php code. That’s the original problem I reported and I still have it.

Questions: Should I turn on the Apache service to have it run as a service or not? I can freely turn it on or off.

I still think there might be something wrong with my installation I got from XAMPP / Bitnami and that is why the today.php file is not executing the way Yank describes in his book that it should.
What do you think of the idea of my uninstalling everything and re-doing the installation the way you did, with a module by module manual installation? If you think this might be a good approach, can you direct me to a site where I can see the instructions for how to do this, please?

N/B: Today’s Apache error log is reporting this:

[Thu Nov 07 15:46:45.527731 2013] [ssl:warn] [pid 27988:tid 244] AH01909: RSA certificate configured for www.example.com:443 does NOT include an ID which matches the server name
[Thu Nov 07 15:46:45.977732 2013] [ssl:warn] [pid 27988:tid 244] AH01909: RSA certificate configured for www.example.com:443 does NOT include an ID which matches the server name
[Thu Nov 07 15:46:47.067733 2013] [mpm_winnt:notice] [pid 27988:tid 244] AH00455: Apache/2.4.4 (Win32) OpenSSL/1.0.1e PHP/5.5.3 configured – resuming normal operations
[Thu Nov 07 15:46:47.067733 2013] [mpm_winnt:notice] [pid 27988:tid 244] AH00456: Server built: Feb 23 2013 12:42:00
[Thu Nov 07 15:46:47.067733 2013] [core:notice] [pid 27988:tid 244] AH00094: Command line: ‘c:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache’
[Thu Nov 07 15:46:47.067733 2013] [mpm_winnt:notice] [pid 27988:tid 244] AH00418: Parent: Created child process 30620
[Thu Nov 07 15:46:47.797734 2013] [ssl:warn] [pid 30620:tid 256] AH01909: RSA certificate configured for www.example.com:443 does NOT include an ID which matches the server name
[Thu Nov 07 15:46:48.157735 2013] [ssl:warn] [pid 30620:tid 256] AH01909: RSA certificate configured for www.example.com:443 does NOT include an ID which matches the server name
[Thu Nov 07 15:46:48.187735 2013] [mpm_winnt:notice] [pid 30620:tid 256] AH00354: Child: Starting 150 worker threads.

What does the ssl and mpm_winnt mean?

Many thanks,

Tom

Well, for the message you’ve got a message from the event viewer, the system only understood the first PHPDir directive…

So obviously the problem is there.

One thing to look… do you have a php.ini file? Because when you install PHP for the first time, php.ini does not exist. You do have a php_recommended.ini (or something similar, I can’t remember the exact name). I would assume that the XAMP installation would have one though.

The second thing is if you really have two Apache installations running and you haven’t changed the ports, they will be in conflict. Do check if you do have two instances of Apache running because that service you’ve got may be XAMP’s installed instance and not a second one. Apache is more efficient when it is run as a service.

The other thing that I can do is to send you my httpd.conf file.

True, I installed Apache and PHP myself, I didn’t install XAMP. The good news is that you can be sure that it works under Windows 7 because it is running in my computer which is, as yours, Windows 7 :slight_smile:

As for the remote connection… tempting but I don’t think we have the same schedules and my advice here is free… I charge for that type of thing :wink:

Molona,

To answer your first question, yes I do have a php.ini file. It is located within the c:/XMAPP/php folder.

I’m not sure I understand your comments about having two installations of Apache running. How to I check for this. I can see one instance of it – a service named Apache2.4 is running – I can see it via my task manager under services.

Can you please send me your httpd.conf file. I would just replace mine (renamed for safe-keeping) with yours, and then rename and relocate my php folder to php5 or whatever else you have that’s different regarding folder names and location.

If this doesn’t work, then I would be willing to pay for the remote connection. I DO WORK LATE AT NIGHT SOMETIMES, LIKE RIGHT NOW – 3:34AM, which seems to coincide with your work hours at least with some overlap. What would be a rate for an hour remote session? I just want to get this working.

thanks,

Tom