0

I am using my laptop as a localhost. I have the following products installed:

  • Apache 2.4
  • PHP 7.1
  • MySQL 5.7

I created a phpinfo.php file in C:\Apache24\htdocs\ with the following code:

<?php
phpinfo();
?>

I also made sure to add this to my Apache config file:

LoadModule php7_module C:/php/php7apache2_4.dll

<ifmodule php7_module="">
DirectoryIndex index.html index.php
AddHandler application/x-httpd-php .php
PHPIniDir "C:/php"
</ifmodule>

When I go to http://localhost/phpinfo.php all I get is:

<?php
phpinfo();
?>

I am expecting some info about my PHP version, etc. So I am getting it to render text within the file, but it doesn't seem to actually process functions.

EDIT: OK, it looks like when I add the line LoadModule php7_module C:/php/php7apache2_4.dll, the Apache service can no longer be restarted.

Pablo Boswell
  • 805
  • 3
  • 13
  • 30
  • 1
    Is PHP running on your machine ? What do you use ? EasyPHP ? Xamp ? – Vincent Decaux Sep 28 '17 at 19:44
  • What's your PHP server? PHP servers should never display the opening and closing tags, that should be loaded on your server. – Sam Sep 28 '17 at 19:49
  • HTML tags? For what? – rndus2r Sep 28 '17 at 19:49
  • I am not sure if I have a server...I also don't know if I am "running" PHP. I just installed everything. I'll look into EasyPHP and Xamp to understand what those are – Pablo Boswell Sep 28 '17 at 19:50
  • It's XAMPP. Besides that, try one of these https://stackoverflow.com/questions/12142172/apache-shows-php-code-instead-of-executing – rndus2r Sep 28 '17 at 19:52
  • Your Apache is not configured to pocess php properly. You might use WAMP, XAMP, OpenServer or another tools wich are configured out of the box. Or you can write your Apache http/host config by your own. – Oleg Lubimoff Sep 28 '17 at 19:53
  • 2
    I don't know about that `` That looks a little odd for some reason. – Don't Panic Sep 28 '17 at 19:53
  • Try it without the `=""`. – Don't Panic Sep 28 '17 at 19:54
  • 1
    You can try to add this line to your Apache conf `AddType application/x-httpd-php .php`, and make sure conf has `LoadModule something_like_php7.dll_or_so` – Oleg Lubimoff Sep 28 '17 at 19:55
  • 1
    I was able to reproduce the problem on my system. With ``, I get PHP code in the browser. With ``, the PHP code is executed. – Don't Panic Sep 28 '17 at 19:57
  • 2
    (Don't forget, you'll need to restart apache after making any configuration changes.) – Don't Panic Sep 28 '17 at 19:58
  • So this is weird, everything was working , but now when I try to restart the service, I get an error that it can't be started... – Pablo Boswell Sep 28 '17 at 20:02
  • @Don'tPanic Do I actually need the ? None of the other modules have that – Pablo Boswell Sep 28 '17 at 20:11
  • Well, probably not, especially since you just loaded the module in the previous line. I only assumed it was there in case there was some problem loading the module, but I think actually if that happened it would cause an error that would keep your server from starting at all. – Don't Panic Sep 28 '17 at 20:13
  • Also I noticed in my Apache config file, that the other LoadModule lines are trying to load .so files....is that right?! – Pablo Boswell Sep 28 '17 at 20:14
  • Yes, that's fine. You can check you apache error log to see why it isn't able to start. – Don't Panic Sep 28 '17 at 20:14
  • @Don'tPanic no error. Last log was the restart shut down, but no log lines created anymore no matter how many times I try to start the service – Pablo Boswell Sep 28 '17 at 20:23
  • Have you tried reversing your slashes? `LoadModule php7_module C:\php\php7apache2_4.dll` - that's usually how Windows rolls. – Typel Sep 28 '17 at 20:30
  • Not sure, but I think my issue was not using 64-bit Apache. But I also installed PHP 7.0 instead of 7.1. I have everything running smoothly now! – Pablo Boswell Sep 28 '17 at 21:22

0 Answers0