I have a PHP 5.3.22 windows server running PHP in fastCGI. It's a Windows Server 2012 but I have also tried this on a Windows Server 2003 box so it does not seem IIS version specific.
If I have a basic PHP page:
<?php
echo 'test';
?>
Why does this take 1 second to load? This overhead seems to stack with further AJAX requests to PHP so this 1 second seems to be adding up.
Basic HTML pages just containing a word "test" from the same server is near instantaneously.
Surly it can’t just be that it takes servers a second to realise this is a PHP file and to prepare PHP for code execution.
I have tried setting the application pool to have more worker processes and to have it’s start mode as “AlwaysRunning” instead of “OnDemand” but alas this seems to have no impact.
Unfortunately changing the PHP version is not an option at this time (would take too long testing, etc).
If it's a clean start, then you shouldn't be experiencing delays anything like that. Perhaps check if you have any plugins or similar running. Xdebug slows down executions, for example.
Related
Good Evening Everyone,
I've been learning PHP and I'm using the built in server to learn the syntax and running simple scripts and web pages. I've been going at it for a better part of 3 weeks now but suddenly this evening. When I try to load my php webpage(s) it would load one page (or hang) then when I'd go to another page I wrote it would either hang or not load at all (Chrome is continuously "waiting on host"). I've been running Windows Server 2016 64 bit (very clean box here). I haven't had any problems with playing with the built in server until today. We are talking about very SIMPLE hello, world scrips with a couple of html tags here or there. I'm using version 7.2.0 64 bit Development Server. I ever tried x86 for giggles and it demonstrates the same behavior.
my command: php -S localhost:8000 (or any open port) I even used my IP to no avail. Suddenly my development sever just stopped working. I've made no changes to my PC.
I'm not receiving any errors or anything when I try to load my pages. What gives? I've made no changes to the ini file. I can attach if needed. Thank You guys so much!
I figured it out there was a command I was running within one of my php scripts that was causing it to hang! It's working now.
I run PHP in CGI mode (that's a requirement for my application). Because of that, if I run ps, by default the processes don't show which php script they are running. They just say "/usr/bin/php".
Since several years ago I've been using, in production, setproctitle to set the process title just like PHP does when running in suPHP.
However, this package appears to be dead and I've never seen it getting a stable version. Plus, it is incomplete and might lead to memory corruption on Linux.
I'm glad to see that there is a native alternative for CLI mode, cli_set_process_title, but is there any alternative for PHP running in a web application?
I need to install large sites locally on two developers workstations. The sites are written in php5 with parts in Zend 1.10 and the database is MySQL. The production server runs on windows server 2003 . The sites are already running on windows vista on a development station and on windows 7 on another one.
On two workstations where i have to install (a windows xp and a windows 7), the same strange phenomenon occurs: after a few successfull requests apache freezes and no longer responds to any query. The site does not work until a reboot of Apache that takes quite a long time (> 30 seconds) . There is nothing in Windows Event Viewer or in the apache logs. Handle.exe tells me nothing and even freezes when apache starts to hang. Windows tasks manager shows nothing unusual. I have compared the host file , php.ini , httpd.conf and httpd.vhost.conf with stations that work without finding any difference.
The configuration includes mod_rewrite , mod_proxy , apc , memcached. Apache version is 2.2 and PHP 5.3.x (thread safe). The code is under version control, database and data directories are synchronized.
Not familiar with windows , I'm looking for tools or assumptions to solve this problem .
I provide some information about a temporary solution I applied. I noticed that a fraction of the php code was executed before Apache freezes.
Execution stops within a Zend Class, Zend_Validate_Ip in the setOptions method. At this time, the file is locked for writing and held by httpd.exe.
I found that this file was slightly different from the original version (Zend 1.11.11) : the require_once have been removed. This is an acceptable optimization recommended by the official documentation.
However, restoring the require_once in that file, the problem is solved. Apache no longer freezes and everything works. So there must be a problem with class loading but I do not understand exactly what it is.
I'm trying to speed up my wordpress site because for some reason it's taking on average 5 seconds to load a page (obviously way too slow). I've tracked it down to the php-cgi.exe hogging an incredibly large amount of cpu time, but now have no idea how to figure out why or how to fix it. Any ideas how I could debug the php-cgi.exe and figure out what is slowing it down?
PHP itself should definitely not be doing that. Are you sure it is PHP, and not the script you are running?
Try a simple Hello World script and see if you notice the same behavior:
<?php echo "Yellow World"; ?>
If you do, try calling it from the command line and see if you have the same problem:
php.exe helloworld.php
If the CLI version executes nice and fast, but the web based one doesn't, you can begin digging into the trouble between your web server and PHP.
Finally, check and make sure a broken or misconfigured extension isn't hanging things up. Remove all extensions you don't need. If you still have trouble, remove them all and add them back in one by one.
Switched to a shared Linux server. All of a sudden everything works without a hitch... start microsoft bashing... now.
There is an IIS bug that causes problems with headers when using a CGI program, and setting a redirect to a page that returns a http 302 (Object Moved). The result is that IIS doesn't parse the headers, so if you're trying to set cookies, it's not going to work. See the KB Article
It says the solution is to start the EXE CGI with -nph (Non parsed Headers) - but I'm not really sure if it works in PHP. I tried adding it to my php file and manually building headers, but that didn't work for me..
Has anyone had this problem? Any good workarounds?
I'm not entirely sure how you're seeing this bug in the modern era.
First, Q17..., er, I mean, KB176113 was published in 1997. The examples list IIS 2.0 as the product affected, and the article itself claims only versions 3-5 are affected. Unless you're running your site on Windows 2000, you aren't using IIS5. Both the article and a bit of time in Google suggests that this problem is entirely fixed in IIS6 and later.
Second, the bug impacts only CGI scripts. If you are using PHP with IIS, then you are either using the ISAPI DLL (and if you are, I'm so sorry), or you're using FastCGI, which despite having three letters in common, is not actually CGI. Nobody has run PHP in CGI mode on IIS since...
You aren't using IIS5, are you?
Okay, if you aren't on IIS7, you might not be running in FastCGI mode. You should totally switch to FastCGI with modern PHP versions. Microsoft spent a lot of time and effort getting PHP and FastCGI playing nicely with IIS.
Third, setting cookies mid-redirect has been buggy in every browser on every platform at one time or another. Are you sure that the cookie header isn't actually being sent? Check your browser's development tools.
Prefixing the PHP file with nph-, not -nph - solved this issue for me.
e.g. nph-test.php