0

A file named test.html contains:

hello

It takes a few milliseconds to respond.

A file named test.php contains:

hello

This one takes a few seconds to respond. They're both the same code and contain no actual PHP code. The file extension is the only difference!

I'm loading both via http://localhost/test.html or php

Is there any common snafu in the server settings that I missed? I'm using the standard Ubuntu 11.04, Apache2, PHP5 configuration.

Your help is appreciated... let me know what other details you need.

6
  • Do you have many PHP modules enabled? Commented Feb 21, 2012 at 20:53
  • In the console run time curl -L --head http://localhost/test.html And check if there is any redirection taking place and report the time. Commented Feb 21, 2012 at 20:56
  • test.html -> real: 5ms, user 4ms, sys 0ms Commented Feb 21, 2012 at 21:04
  • test.php -> real: 4.874s, user: 0ms, sys: 0ms Commented Feb 21, 2012 at 21:05
  • There wasn't any redirection, just HTTP/1.1 200 OK Commented Feb 21, 2012 at 21:07

3 Answers 3

1

Well even if there is no actual php code in your php file its getting sent to the php parser by apache because of its extension. This probably slows it by a few miliseconds and on your system might be more.

Like others have pointed out you probably have some module that is taking too much time. But about your original question my answer stands. Even without code your php file is getting parsed by php.

Sign up to request clarification or add additional context in comments.

3 Comments

Agreed but I'm saying it takes closer to 5 seconds. If it was just a few milliseconds there'd be no problem.I don't think my speedy system should take so long... there's got to be something funny going on.
Well then its probably a module problem like others have pointed out. But the fact you have no code in your script wont change that.
OK, thanks! It is definitely triggered by the php extension... no doubt about that!
1

If you want to get an idea what is going on try the following:

sudo -i
stop apache2
. /etc/apache2/envvars
apache2 -k start -X &
strace  -u www-data -tt -ff -o /tmp/strace $(ps -o "-p %p" h -u www-data) &

man strace to find out what it does and don't forget to apache2 -k stop and start apache2 when you are done :) Remember you are all-powerful as root so come out ASAP.

Try adding an .htaccess file and also doing a sudo apt-get install php-apc to see how an Opcode cache works. The next stage is to strart downloading the source and matching this up to what is happening in the system trace. Enjoy.

Comments

0

Even though there's no PHP code, it is being parsed as PHP. The problem could exist with Apache's configuration / installed modules, or possibly if you have a bunch of (or any one problematic) enabled module(s) in PHP.

5 Comments

How would I track a problematic module down?
Here are my modules: core mod_log_config mod_logio prefork http_core mod_so mod_alias mod_auth_basic mod_authn_file mod_authz_default mod_authz_groupfile mod_authz_host mod_authz_user mod_autoindex mod_cgi mod_deflate mod_dir mod_env mod_mime mod_negotiation mod_php5 mod_reqtimeout mod_rewrite mod_setenvif mod_status mod_usertrack
OK, I went to /etc/php5/apache2/conf.d and starting commenting out all the extension=blah commands in each file. Right now I only have mysql and mysqli enabled and it is RUNNING FAST! Thanks to everyone who contributed... I hope this helps someone. The PROBLEM module seems to be clamav, an anti-virus program.
Here's an article about clamav slowing down PHP: biggleszx.com/2007/08/solving-slow-apachephp-culprit-clamav
Yeah, I'd keep my plugins to a minimum. I think anti-virus is certainly something that falls outside the scope of a web server's duties... Be sure to select an answer if one helped you out! Welcome to SO.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.