0

I'm having problem with opening php pages in browser. I'm using apache web server and the problem is that instead of a page browser shows php code that i wrote in text editor (for example it shows <?php phpinfo(); ?> instead list with informations about php).
Everything worked fine before I've read somewhere that I have to put code PHPIniDir "E:/PHP" (thats location of my php.ini file) in the httpd.conf.
After I did that browser wouldn't show php pages any more. Then I deleted the code but the problem remained.
What did i mess up?

After every change to httpd.conf I stopped and started again apache, but nothing changed.

3
Contributors
9
Replies
10
Views
8 Years
Discussion Span
Last Post by kireol
0

Hey.

The most likely causes for that are:

  1. You used short_open_tags without enabling them. (<? ... ?> instead of <?php ... ?>)
  2. Your PHP files have an incorrect file extension. People new to PHP often try to add PHP code to their old .html files without changing the extension to .php
  3. Apache isn't configured to use PHP. Generally, all you have to do is add the following to the httpd.conf file: (Apache 2.2 with PHP5)
    PHPIniDir "E:/PHP/"
    LoadModule php5_module "E:/PHP/php5apache2_2.dll"

    You may also need to specify the mime type for the .php extension:

    AddType application/x-httpd-php .php

    Then there are the minor tweaks, like allowing index.php to be an index file:

    <IfModule dir_module>
        DirectoryIndex index.html index.php
    </IfModule>

P.S.
You could just use something like XAMPP to set all this up for you, and you won't have to worry about any of this stuff.

Edited by Atli: Typos.

0

What OS are you running? Windows? Linux? Sounds to me like PHP isnt installed.

... I've read somewhere that I have to put code PHPIniDir "E:/PHP" (thats location of my php.ini file) ...

Says it all, doesn't it ;)

Edit, in case it doesn't:
The location "E:/PHP" he mentioned would indicate that he uses windows, and that he tells us this is the location of his php.ini would indicate that PHP is in fact installed.

Edited by Atli: Clarifying.

0

besides he COULD be wineing apache ;)

True, as horrific as that sounds :)
But in that case a minor glitch in the PHP support should be the least of his worries!

P.S.
For some reason, I've now got the urge to go set up Apache in Wine xD

0

For some reason, I've now got the urge to go set up Apache in Wine xD

lol! i was thinking the same.

0

What OS are you running? Windows? Linux? Sounds to me like PHP isnt installed.

I'm running Windows, apache and php are installed and everything worked fine till now.

The most likely causes for that are:
You used short_open_tags without enabling them. (<? ... ?> instead of <?php ... ?>)

It's the same if i try with <?php...?>

Your PHP files have an incorrect file extension. People new to PHP often try to add PHP code to their old .html files without changing the extension to .php

Extension is also fine, it's .php on evry file.

Apache isn't configured to use PHP. Generally, all you have to do is add the following to the httpd.conf file: (Apache 2.2 with PHP5)

PHPIniDir "E:/PHP/"
LoadModule php5_module "E:/PHP/php5apache2_2.dll"

You may also need to specify the mime type for the .php extension:

AddType application/x-httpd-php .php

Then there are the minor tweaks, like allowing index.php to be an index file:

<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>

When i first installed apache and php, I added this to the end of the httpd.config:

LoadModule php5_module "e:/php/php5apache2.dll"
AddType application/x-httpd-php .

It worked fine until now when I added

PHPIniDir "E:/PHP/"

I think I messed up something with this because since I added it, I can't open pages in browser properly any more. Even when I deleted PHPIniDir "E:/PHP/" nothing changed.

I first put it to the end, like this:

LoadModule php5_module "e:/php/php5apache2.dll"
AddType application/x-httpd-php .
PHPIniDir "E:/PHP/"

instead like this:

PHPIniDir "E:/PHP/"
LoadModule php5_module "e:/php/php5apache2.dll"
AddType application/x-httpd-php

I also first set wrong path (PHPIniDir "C:/PHP/").

Maybe something of that caused problems.

0

Ok, it's either some mystery or I didn't explain it well.
Anyway, thanks for help, I'll try with xampp or wamp.

0

if you've tripple checked the location of the module, tripple checked your add type is there, sure you are using the right conf file, sure your dll is fine, then i'd try to reinstall. Actually i'd install ubuntu and be done with it. but thats me.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.