Apache running but php won't!

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Apache running but php won't!

Postby Max Kite » 26. August 2015 18:43

New to this. Just want to practice my php scripting without FTPing a website. I have resolved the problems discussed elswhere on this forum on my laptop and control panel is working in everything from administrator (Apache through to Tomcat showing 'RUNNING') and I get the localhost welcome page and can click on phpinfo from that page and it works fine, but I can doubleclick a .php file in the same directory/sub-directory such as htdocs and it will run in a browser (Firefox) but only as an HTML file. The same is true calling a .php file using <a href...> from an html file.

I'm running Win8.1 on an ASUS Laptop. XAMPP Control Panel v3.2.1 as downloaded 1 week ago. XAMPP v5.6.11

HELP please!!!

Error logs:

[Wed Aug 26 11:30:42.155048 2015] [ssl:warn] [pid 7060:tid 476] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Wed Aug 26 11:30:42.325101 2015] [core:warn] [pid 7060:tid 476] AH00098: pid file D:/Data/Data/XAMPP2/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Wed Aug 26 11:30:42.536169 2015] [ssl:warn] [pid 7060:tid 476] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Wed Aug 26 11:30:42.660211 2015] [mpm_winnt:notice] [pid 7060:tid 476] AH00455: Apache/2.4.16 (Win32) OpenSSL/1.0.1p PHP/5.6.11 configured -- resuming normal operations
[Wed Aug 26 11:30:42.660211 2015] [mpm_winnt:notice] [pid 7060:tid 476] AH00456: Apache Lounge VC11 Server built: Jul 12 2015 10:56:48
[Wed Aug 26 11:30:42.660211 2015] [core:notice] [pid 7060:tid 476] AH00094: Command line: 'D:\\data\\data\\xampp2\\apache\\bin\\httpd.exe -d D:/Data/Data/XAMPP2/apache'
[Wed Aug 26 11:30:42.664210 2015] [mpm_winnt:notice] [pid 7060:tid 476] AH00418: Parent: Created child process 676
[Wed Aug 26 11:30:44.285731 2015] [ssl:warn] [pid 676:tid 368] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Wed Aug 26 11:30:44.659852 2015] [ssl:warn] [pid 676:tid 368] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Wed Aug 26 11:30:44.838909 2015] [mpm_winnt:notice] [pid 676:tid 368] AH00354: Child: Starting 150 worker threads.

I used an old version of Apache on XP for many happy years php-ing without any problems but this one is baffling me. :(
Max Kite
 
Posts: 4
Joined: 26. August 2015 18:24
Operating System: Windows 8.1

Re: Apache running but php won't!

Postby Altrea » 26. August 2015 18:50

PHP is a serverside programming language means the files need to be processed by an interpreter first.
You cannot simply open the files in your browser. Your browser does not have a clue that php files need to be processed first and that there is a interpreter installed on the same machine the request comes from.

so save your files at a place Apache can access them ( e.g. C:\xampp\htdocs\subfolder\filename.php ) and request the file by URL http://localhost/subfolder/filename.php
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8290
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: Apache running but php won't!

Postby Max Kite » 27. August 2015 23:40

Thanks for that Altrea but I can't get anything to run in the browser under localhost except as html, either using the browser or calling a .php file from an html file. For example, index.html runs fine and dandy but when I click on 'About us' the browser calls 'aboutus.php' but only runs it as an .html file ignoring the php script. This is all inside 'localhost'.

When I had Apache running on my old laptop under XP (RIP) I could click on any file in the XAMPP directory (or its daughters e.g. htdocs) with a .php extension and it would run as a php script perfectly. At the moment XAMPP Control Panel is showing everything running (I've tried it as system service and not) but the php interpreter doesn't seem to be running. McAffee antivirus is disabled.

I have XAMPP installed on the D drive - does that matter? Very frustrating.
Max Kite
 
Posts: 4
Joined: 26. August 2015 18:24
Operating System: Windows 8.1

Re: Apache running but php won't!

Postby Altrea » 27. August 2015 23:50

Which address does your browsers address bar show at the moment you are thinking your php don't get parsed?
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8290
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: Apache running but php won't!

Postby Nobbie » 28. August 2015 10:57

Max Kite wrote:When I had Apache running on my old laptop under XP (RIP) I could click on any file in the XAMPP directory (or its daughters e.g. htdocs) with a .php extension and it would run as a php script perfectly


But only if you are viewing the directory via a Browser and via http://localhost/.... but not via Windows Explorer. I am very sure that you are mixing up all these things. If you simply double click a HTML file and/or a PHP File in your Explorer, this will not work (it will happen exactly that, what happens now). Instead you MUST enter http://localhost/directory (where "directory" is a directory under your htdocs directory) and if you can see a directory listing there (this requires certain configuration), then and only then you may click on a PHP file and it will be processed correctly. The browser MUST show "http://....." in the URL and it MUST NOT show "file://...." in the URL. Check that out.
Nobbie
 
Posts: 8768
Joined: 09. March 2008 13:04

Re: Apache running but php won't!

Postby Max Kite » 28. August 2015 15:43

My XAMPP is installed in D/Data/Data/XAMPP2. I start Apache etc. by
1) disabling McAffee
2) Right clicking on XAMPP-Control.exe which loads and shows Apache, MySQL etc. running.
3) In Firefox, I load http://index.php as there is such a file in the XAMPP2 directory (as well as the htdocs subdirectory)
4) The address window then briefly goes to www.index.php (1/10 second) and then http://advancedsearch2.virginmedia.com/main?ParticipantID=jqlc435pa.........which shows:
www.index.php is unavailable or may not exist

Try searching from the search box, or pick a match from below".

5) Typing http://localhost in the window converts to localhost/dashboard and displays the Apache welcome screen.

I have tried a large number of experimental addresses such as http://XAMPP/htdocs/index.php and nothing runs.

I understand from Larry Ullman's php book that any .php file in the directory from where Apache is running should be parsed by Apache as it is running continuously in the background.

I have confirmed that XAMPP is running out of that directory from Shell:

"Setting environment for using XAMPP for Windows.
ASUS@MAXNEWLAPTOP d:\data\data\xampp2"

A strange thing has just happened - it is now working perfectly, parsing php. I have no idea how or why. The address window (working) now shows:

"http://localhost/141208full/main/aboutus.php". This file is in the XAMPP2/htdocs/141208full/etc. directory.

Thank you to all posters for your help.
Max Kite
 
Posts: 4
Joined: 26. August 2015 18:24
Operating System: Windows 8.1

Re: Apache running but php won't!

Postby Max Kite » 28. August 2015 15:48

Line 2) should read "2) Right clicking on XAMPP-Control.exe and selecting 'Run as administrator' which loads and shows Apache, .....
Max Kite
 
Posts: 4
Joined: 26. August 2015 18:24
Operating System: Windows 8.1

Re: Apache running but php won't!

Postby Nobbie » 29. August 2015 12:32

Max Kite wrote:My XAMPP is installed in D/Data/Data/XAMPP2. I start Apache etc. by


You mean D:/... (there is missing a colon)?

Max Kite wrote:3) In Firefox, I load http://index.php as there is such a file in the XAMPP2 directory (as well as the htdocs subdirectory)
4) The address window then briefly goes to www.index.php (1/10 second) and then http://advancedsearch2.virginmedia.com/ ... .....which shows:
www.index.php is unavailable or may not exist


Of course, this is complete nonsense. You have to specify a host name, usually "localhost" or an IP in that line. For example: http://localhost/index.php


Max Kite wrote:5) Typing http://localhost in the window converts to localhost/dashboard and displays the Apache welcome screen.


Thats the way it works.

Max Kite wrote:I have tried a large number of experimental addresses such as http://XAMPP/htdocs/index.php and nothing runs.


Because this is nonsense. Again, you have to specify a host name. You should read some tutarials about Apache, Webservers and how it all works. Its useless to enter invalid URLs into the browser. You cannot enter a plain Pathname there, you have to specify a server (a hostname), this is the way, the internet is working. In your case, the server (host name) is "localhost". And when the browser sents a requets to that server (in your case, the browser runs on the same PC as the server, but it still behaves like a normal request), the server looks up a certain Path in order to find the requested file (index.php). And the Path, which is searched by Apache, is defined in the Apache Configuration by the value of "DocumentRoot".

Running and administrating a webserver is by far not a simple task and you really should read some documentation about it, before "fiddling around" and doing useless things.
Nobbie
 
Posts: 8768
Joined: 09. March 2008 13:04


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 86 guests