Jump to content

PHP Scripts not interpreted in Apache 2.2.2


Recommended Posts

Hi, all. I just have a futile search for already posted answers for my question.

Here's my problem : I've installed Apache 2.2.2 httpd a long time ago and had no problem running and seeing the html pages. But recently I wanted to rekindle myself with PHP, so I downloaded PHP 5.2.5 binary package and unzip it to my c:/php.

 

I've added these lines in httpd.conf :

 

LoadModule php5_module "c:/php/php5apache2_2.dll"

AddType application/x-httpd-php .php

PHPIniDir "c:/php"

 

The server runs without errors and it is able to read php files, but it doesn't interpret the scripts. It just outputs the whole file as plain html. I've tried to search error logs and stuffs but in vain. Please help me figure out why is this happening. It's been two days. FYI, running php scripts from console using php.exe works normally.

Link to comment
Share on other sites

Show us a script you have tired, including the opening and closing php tags you are using.

 

There could be hundreds of things wrong and we only see the information in your post. The more information about what you have tried and what you see, the better the help that can be provided. Showing actual code you tried will help pin down the area the problem is in.

Link to comment
Share on other sites

ok, i've tried creating a couple of files.

 

first.php :

 

<html>

<head>

<title>This is my first PHP in 2008</title>

</head>

<body>

Test test test

<?php printf("Hello, World!!"); ?>

</body>

 

</html>

 

 

or second.php :

<html>

<head><title>Second PHP file</title></head>

<body>

<?php phpinfo(); ?>

</body>

</html>

 

 

the first.php output the text "Test test test " and the title is shown correctly. But the Hello, World!! did not show, and the when I view the HTML source, it is exactly as the script file content.

 

the second.php also behaved the same as the first one.

phpinfo(); didn't output anything. But shown in the HTML result as it is in the script file.

 

Link to comment
Share on other sites

The changes you show for httpd.conf are correct (assuming they were not put into any conditional blocks, that the httpd.conf that you changed is the one that Apache is using, and that you stopped and started Apache to get it to read the changes made to httpd.conf.)

 

What address are you typing into your browser to get to these files?

 

You have checked the Apache error log file and there are no startup errors?

Link to comment
Share on other sites

the address I used is

http://localhost/first.php and http://localhost/second.php

I'm sure that the apache server has located them correctly, otherwise it would have shown error messages instead. I've tried uninstalling and re-installing the apache server, even replacing it with the 2.2.8 version. Let the installer does all the configuration. Nothing seems to work.

I've tried to put the AddType without a <IfDefine php5_module> tag, AND without the tag. Still the same. No errors, but the script isn't processed.

 

Oww, and I've checked the error log file in the logs folder. Both errors.log and access.log. There's no error. Here's the error.log content :

 

Starting the Apache2.2 service

The Apache2.2 service is running.

] Apache/2.2.8 (Win32) configured -- resuming normal operations

[Mon Mar 10 15:15:24 2008] [notice] Server built: Jan 18 2008 00:37:19

[Mon Mar 10 15:15:24 2008] [notice] Parent: Created child process 5584

[Mon Mar 10 15:15:24 2008] [notice] Child 5584: Child process is running

[Mon Mar 10 15:15:24 2008] [notice] Child 5584: Acquired the start mutex.

[Mon Mar 10 15:15:24 2008] [notice] Child 5584: Starting 64 worker threads.

[Mon Mar 10 15:15:24 2008] [notice] Child 5584: Starting thread to listen on port 80.

[Mon Mar 10 15:19:59 2008] [warn] pid file C:/Program Files/Apache Software Foundation/Apache2.2/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?

[Mon Mar 10 15:19:59 2008] [notice] Apache/2.2.8 (Win32) configured -- resuming normal operations

[Mon Mar 10 15:19:59 2008] [notice] Server built: Jan 18 2008 00:37:19

[Mon Mar 10 15:19:59 2008] [notice] Parent: Created child process 1208

[Mon Mar 10 15:19:59 2008] [notice] Child 1208: Child process is running

[Mon Mar 10 15:19:59 2008] [notice] Child 1208: Acquired the start mutex.

[Mon Mar 10 15:19:59 2008] [notice] Child 1208: Starting 64 worker threads.

[Mon Mar 10 15:19:59 2008] [notice] Child 1208: Starting thread to listen on port 80.

[Mon Mar 10 15:25:56 2008] [error] [client 127.0.0.1] File does not exist: C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/favicon.ico

[Mon Mar 10 15:26:57 2008] [notice] Parent: Received restart signal -- Restarting the server.

[Mon Mar 10 15:26:57 2008] [notice] Child 1208: Exit event signaled. Child process is ending.

[Mon Mar 10 15:26:58 2008] [notice] Apache/2.2.8 (Win32) configured -- resuming normal operations

[Mon Mar 10 15:26:58 2008] [notice] Server built: Jan 18 2008 00:37:19

[Mon Mar 10 15:26:58 2008] [notice] Parent: Created child process 1088

[Mon Mar 10 15:26:58 2008] [notice] Child 1208: Released the start mutex

[Mon Mar 10 15:26:58 2008] [notice] Child 1088: Child process is running

[Mon Mar 10 15:26:58 2008] [notice] Child 1088: Acquired the start mutex.

[Mon Mar 10 15:26:58 2008] [notice] Child 1088: Starting 64 worker threads.

[Mon Mar 10 15:26:58 2008] [notice] Child 1088: Starting thread to listen on port 80.

[Mon Mar 10 15:26:59 2008] [notice] Child 1208: All worker threads have exited.

[Mon Mar 10 15:26:59 2008] [notice] Child 1208: Child process is exiting

 

Link to comment
Share on other sites

PHP maybe crashing when Apache starts up. This maybe due to a PHP configuration issue. You should have a php.ini file in the root of your PHP folder (C:/php). Rename this file to php.ini.old

 

Restart Apache. Does your PHP scripts now work? If they do rename php.ini.old back to php.ini and open it for editing, search for a setting called display_startup_errors and change the default value Off to On (should be around line 377). Save the php.ini and restart Apache. PHP should display error prompts when Apache starts up.

Link to comment
Share on other sites

Hi, I've done what you told me. Ok, first, I renamed the php.ini to php.ini.old, then restarted the apache server. Here's the new error.log entries :

 

[Tue Mar 11 07:13:09 2008] [notice] Apache/2.2.8 (Win32) PHP/5.2.5 configured -- resuming normal operations

[Tue Mar 11 07:13:09 2008] [notice] Server built: Jan 18 2008 00:37:19

[Tue Mar 11 07:13:09 2008] [notice] Parent: Created child process 1512

[Tue Mar 11 07:13:10 2008] [notice] Child 1512: Child process is running

[Tue Mar 11 07:13:10 2008] [notice] Child 1512: Acquired the start mutex.

[Tue Mar 11 07:13:10 2008] [notice] Child 1512: Starting 64 worker threads.

[Tue Mar 11 07:13:11 2008] [notice] Child 1512: Starting thread to listen on port 80.

 

Still, php scripts seems to be treated as a html comment tag, it seems apache ignores the script. Then, I renamed the php.ini.old back to php.ini. Changed the display_startup_errors to On. But no error prompts came up. And error.log showed no differences :

 

[Tue Mar 11 07:16:20 2008] [notice] Apache/2.2.8 (Win32) PHP/5.2.5 configured -- resuming normal operations

[Tue Mar 11 07:16:20 2008] [notice] Server built: Jan 18 2008 00:37:19

[Tue Mar 11 07:16:20 2008] [notice] Parent: Created child process 2152

[Tue Mar 11 07:16:20 2008] [notice] Child 2152: Child process is running

[Tue Mar 11 07:16:21 2008] [notice] Child 2152: Acquired the start mutex.

[Tue Mar 11 07:16:21 2008] [notice] Child 2152: Starting 64 worker threads.

[Tue Mar 11 07:16:21 2008] [notice] Child 2152: Starting thread to listen on port 80.

 

Anyway, I'm using WinXP and I've checked the env variable Path. It already has C:/php in it. I can call php from the console just fine. This is very confusing. I may have missed something, but what? Maybe something stupid, but it's been three days now.

 

Link to comment
Share on other sites

Is it possible that the settings in internet browsers or firewall blocks php processes? Doesn't make sense, cause I can see php pages from other sites perfectly, using IE or Firefox. I recently tried reinstalling PHP to another directory, with no effect.

 

In php.ini, changed the language options to enable the <% %> and <? ?> tags and added the scripts using those three types of tags, but they all treated as simple tags by apache. I turned on the display_error, log_error to On and set the errors_log to php_errors.log. But it seems no error anywhere occured. Here's some snippets :

 

[pre]

;;;;;;;;;;;;;;;;;;;;

; Language Options ;

;;;;;;;;;;;;;;;;;;;;

 

; Enable the PHP scripting language engine under Apache.

engine = On

 

; Enable compatibility mode with Zend Engine 1 (PHP 4.x)

zend.ze1_compatibility_mode = Off

 

; Allow the <? tag.  Otherwise, only <?php and <script> tags are recognized.

; NOTE: Using short tags should be avoided when developing applications or

; libraries that are meant for redistribution, or deployment on PHP

; servers which are not under your control, because short tags may not

; be supported on the target server. For portable, redistributable code,

; be sure not to use short tags.

short_open_tag = On

 

; Allow ASP-style <% %> tags.

asp_tags = On

 

[/pre]

 

[pre]

error_reporting  =  E_ALL

 

; Print out errors (as a part of the output).  For production web sites,

; you're strongly encouraged to turn this feature off, and use error logging

; instead (see below).  Keeping display_errors enabled on a production web site

; may reveal security information to end users, such as file paths on your Web

; server, your database schema or other information.

;

; possible values for display_errors:

;

; Off          - Do not display any errors

; stderr      - Display errors to STDERR (affects only CGI/CLI binaries!) 

; On or stdout - Display errors to STDOUT (default)

; To output errors to STDERR with CGI/CLI:             

;display_errors = "stderr"

;

; Default

;

display_errors = On

 

; Even when display_errors is on, errors that occur during PHP's startup

; sequence are not displayed.  It's strongly recommended to keep

; display_startup_errors off, except for when debugging.

display_startup_errors = On

 

; Log errors into a log file (server-specific log, stderr, or error_log (below))

; As stated above, you're strongly advised to use error logging in place of

; error displaying on production web sites.

log_errors = On

 

; Set maximum length of log_errors. In error_log information about the source is

; added. The default is 1024 and 0 allows to not apply any maximum length at all.

log_errors_max_len = 1024

 

; Do not log repeated messages. Repeated errors must occur in same file on same

; line until ignore_repeated_source is set true.

ignore_repeated_errors = Off

 

; Ignore source of message when ignoring repeated messages. When this setting

; is On you will not log errors with repeated messages from different files or

; source lines.

ignore_repeated_source = Off

 

; If this parameter is set to Off, then memory leaks will not be shown (on

; stdout or in the log). This has only effect in a debug compile, and if

; error reporting includes E_WARNING in the allowed list

report_memleaks = On

 

;report_zend_debug = 0

 

; Store the last error/warning message in $php_errormsg (boolean).

track_errors = Off

 

; Disable the inclusion of HTML tags in error messages.

; Note: Never use this feature for production boxes.

;html_errors = Off

 

; If html_errors is set On PHP produces clickable error messages that direct

; to a page describing the error or function causing the error in detail.

; You can download a copy of the PHP manual from http://www.php.net/docs.php

; and change docref_root to the base URL of your local copy including the

; leading '/'. You must also specify the file extension being used including

; the dot.

; Note: Never use this feature for production boxes.

;docref_root = "/phpmanual/"

;docref_ext = .html

 

; String to output before an error message.

;error_prepend_string = "<font color=ff0000>"

 

; String to output after an error message.

;error_append_string = "</font>"

 

; Log errors to specified file.

error_log = php_errors.log

[/pre]

Link to comment
Share on other sites

  • Do I need to add lines to include any extension in php.ini in order for apache & php to work?
  • Is there any glitch with the Apache 2.2.8 and PHP 5.2.5 that doesn't allow them to interact?
  • Could it be my Norton Antivirus that blocks the scripts from getting processed?

 

Please, anyone, help me.

Link to comment
Share on other sites

Do I need to add lines to include any extension in php.ini in order for apache & php to work?

No, this is handled by Apache.

 

Is there any glitch with the Apache 2.2.8 and PHP 5.2.5 that doesn't allow them to interact?

No, PHP is compatible with Apache2.2.x

 

Could it be my Norton Antivirus that blocks the scripts from getting processed?

I don't think so. If Norton was interfering then Apache will fail to work.

 

Seems strange to me. There must be something else interfering. Can you link your httpd.conf and php.ini here so I can have a look.

Link to comment
Share on other sites

Arghhhh... the strangest thing has just happened. For the last 3 days I've been changing httpd.conf and php.ini but kept trying to run the same php files. And the results were all the same, nothing happened. Today, I tried making a new php file and run it, and it worked perfectly. So, my guess is that either php or apache has a cache system somewhere that detects if the user is accessing a "previously have been run" script files. That's why I've been getting the same results. I think my apache and php now works just fine. Thank you PFMaBiSmAd and wildteen88. I really appreciate your help.

Link to comment
Share on other sites

Hi, yeah thanks.

 

I presumed it's not the browser, cause I checked the scripts both in IE and Firefox, and have done the Ctrl+F5 thing. Either IE and Firefox share the same cache system or Apache the culprit or... it's probably the char encoding in the php files. I used ultraedit for the first and second script (which didn't work), but used dreamweaver for the other scripts. Anyway, this I cannot tell also, since I'm pretty much a noob in php :D.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.