1

I have apache installed. I was doing just fine until today, that I created a php file and so apache did not open it. I then searched the web and I realized I needed to install php (I come from Linux so I never needed to do this). I followed some tutorials (here, and here), but none of this work. I have researched a bit so I can outright discard the most common things, that I list below.

  1. My file has a php extension (and ini file is configured to read ".php" files)
  2. Apache "httpd-conf" file is modified as follows:

# PHP7 module LoadModule php7_module "C:/php/php7apache2_4.dll" AddType application/x-httpd-php .php PHPIniDir "C:/php"

  1. httpd -t turns just fine
  2. And so does php -v
  3. My php.ini file has been "uncommented" as the 1st webpage I refer suggests
  4. I already added the environment route to my PC

So, any clue? Something is wrong with what I've done? Can it be a matter of installing Apache BEFORE php? That's the only thing I can think of, after researching and trying every fix suggested in this and other websites, is the only "logical" explanation I can think of (besides forgeting something not as common or following the wrong "tutorial").

Thanks!!

EDIT:

I suspect something is wrong because apache is only displaying code when I'm loading some php file. If my php code contains some html, this one is correctly displayed but not the php part (I checked for syntax issues among the php code and turned just fine).

Later I decided to try loading the following:

<? php phpinfo(); ?>

On an index.php file (I tried using a different name and specifying it as localhost/test.php) but is just displays a blank page.

EDIT2:

Here are the versions I am using:

PHP 7.3.9 (TS) x64 Apache 2.4.41 x64

EDIT3:

Downgraded to PHP 7.2.22, still not working. I did some changes as suggested on various websites (basically adding things to the httpd-conf file), and checked for syntax as previously. Still none of this worked. I tried to start apache and load the "localhost" page with my index.php (the test script) on it and check for the logs in hope of finding some issue. As I'm no expert I would say logs turned just fine, but I paste them in here just in case someone notices anything weird.

LOGS:

[Wed Sep 04 10:40:34.234726 2019] [mpm_winnt:notice] [pid 7276:tid 768]

AH00455: Apache/2.4.41 (Win64) PHP/7.3.9 configured -- resuming normal operations

[Wed Sep 04 10:40:34.234726 2019] [mpm_winnt:notice] [pid 7276:tid 768]

AH00456: Apache Lounge VS16 Server built: Aug 9 2019 16:46:32

[Wed Sep 04 10:40:34.234726 2019] [core:notice] [pid 7276:tid 768] AH00094:

Command line: 'C:\Apache24\bin\httpd.exe -d C:/Apache24'

[Wed Sep 04 10:40:34.234726 2019] [mpm_winnt:notice] [pid 7276:tid 768]

AH00418: Parent: Created child process 8232

Apache server shutdown initiated...

pm_winnt:notice] [pid 8232:tid 784] AH00354: Child: Starting 64 worker threads.

[Wed Sep 04 10:41:33.635398 2019] [mpm_winnt:notice] [pid 7276:tid 768]

AH00422: Parent: Received shutdown signal -- Shutting down the server.

[Wed Sep 04 10:41:35.666154 2019] [mpm_winnt:notice] [pid 8232:tid 784]

AH00364: Child: All worker threads have exited.

[Wed Sep 04 10:41:35.681785 2019] [mpm_winnt:notice] [pid 7276:tid 768]

AH00430: Parent: Child process 8232 exited successfully.

The "-- Shutting down the server."" was me closing the application at 10:41 AM

Hope this is useful

  • 1
    How exactly does it not work? – Daniel B Sep 2 at 15:17
  • Hi! Whenever I load a php file it shows me the code and just "runs" the html code inside my php file. I tried to do the phpinfo() test in a php file and sure enough, nothing shows, just a blank page. I'll edit my question adding this info too! – N00b Sep 3 at 6:22
  • @N00b It might be worthwhile to specify the actual versions/sources of Apache and PHP you are using. – Anaksunaman Sep 3 at 16:16
0

As a thought, you may wish to consider verifying your version of PHP is suitable for your version of Apache. This might include:

  • Verifying both PHP and Apache were compiled with compatible compilers.

  • Verifying both were compiled in 32-bit or 64-bit formats.

  • Make sure that your are using a Thread Safe (TS) versions of PHP.

  • Considering downgrading or otherwise switching versions if you are using an early version of 7.4 (up to and including 7.4.0beta2).

Edit

The log information shows you are running an Apache Lounge build of Apache, which is compatible with PHP 7.3.9 for certain.

I tried to do the phpinfo() test in a .php file and sure enough, nothing shows, just a blank page.

This is typical of syntax errors with PHP. Looking back over your original post, your <? php phpinfo(); ?> command should be <?php phpinfo()?>. Running <? php phpinfo(); ?> with a known, working PHP installation (Apache Lounge Apache v2.4.41 VS16 x32 with PHP 7.3.9 VC15 TS x32) yielded a blank page as well.

  • Thanks for your answer! I'm not sure if that is what you are requiring (in case it is I will update my original question). PHP has a module named php7apache2_4.dll which "should" mean that they are compatible. I have both the 32-bit versions I downloaded the TS version of PHP although I've seen in some posts and forums that that might not be the optimal version for windows (I did not get the reason why, so I went the safe path...) I'm now in process of downgrading PHP (as I understand that is possibly the problem, more than being apache) PHP ver: 7.3.9 (TS) x64 Apache ver: 2.4.41 x64 – N00b Sep 4 at 6:23
  • Downgrade to php 7.2.22 did not work. I have the exact same issue... – N00b Sep 4 at 7:00
  • Looking back over your original post, your <? php phpinfo(); ?> command should be <?php phpinfo()?>. Running <? php phpinfo(); ?> with a known, working PHP installation (Apache Lounge Apache VS16 x32 with PHP 7.3.9 TS x32) yielded a blank page as well. I suggest you try phpinfo() again and see if PHP is working for you. – Anaksunaman Sep 4 at 23:15
  • What a "dumb" error. It works!! I don't get why though, as I thought semicolon ; are needed on php syntax... Well, I think I might study things a little bit more. I was so obsessed with messing with configuration files I would have never guessed the error was on the syntax itself. Many thanks! – N00b Sep 5 at 6:52
  • No problem whatsoever. =) I sympathize with you on the PHP syntax. ; are typically needed. Just not in this case. =P Anyhow, I am glad things are working as they should be. – Anaksunaman Sep 5 at 7:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.