Long delay to load PHP in IIS over fileshare - php

I have a new IIS 10 / Server 2019 server, which uses a SMB file share for app data. My problem is, for PHP sites there is a delay of about 2 minutes and 15 seconds for a simple "hello world" website to start. Even stranger, it does it on all sites with PHP 7.x, but not on 5.x unless it's a more complicated site like Mediawiki. It also only does it when loaded over the fileshare, which is otherwise quick to access. Once loaded the first time it runs quickly for about 3 min until whatever loaded process has to reload from scratch again. Using the error log, I can see that PHP loads the ini instantly and will complain about formatting errors and such right away, but the first line of a php page does not load until the last second. PHP xdebug also doesn't seem to note anything until the last second of loading.
It certainly seems like something is trying to resolve and timing out, but using //192.168.1.x doesn't work any better than //fileshare. I've poured through the php.ini looking for a culprit but can't find it. Any help is greatly appreciated!
The main settings I've messed with are the ones below with different combinations and ways of writing the path.
cgi.force_redirect = 0
cgi.fix_pathinfo = 1
fastcgi.impersonate = 1
fastcgi.logging = 0
track_errors = Off
soap.wsdl_cache_dir = C:\inetpub\php_temp
error_log = "C:\inetpub\php_errors\php_error73.txt"
upload_tmp_dir = C:\inetpub\php_temp
sys_temp_dir = C:\inetpub\php_temp
session.save_path = C:\inetpub\php_temp

Managed to trace it down to two odd culprits.
The main time out issue was:
user_ini.filename =
By default it's commented out in php.ini, so removing the semi colon disabled that feature which must have had trouble searching for ini files on the file share.
Second issue on 5.x seemed to be related to having the old mysql plugin enabled. Leaving it enabled didn't seem to matter on local disk, but having it enabled caused issues on the file share. I'm using mysqli in code, so no problem disabling it for me.

Related

PHP Session Start Fatal error: Can't use function return value in write | Following Extensive Troubleshooting

Fatal error: Can't use function return value in write on line 3
I've looked extensively for an answer to my specific situation with no progress. Please review what I've already tried and I've included my VPS global php.ini file. No php.ini files exist within the website root.
<?php
session_start();
?>
<!DOCTYPE html>
<html>
I have no idea how that's possible. Please check out what I've already done to try to solve the problem.
Problem originated when I was unable to pass variables to another page using
$_SESSION['$example'] variables with no luck. But I'll worry about that next.
VPS System Specs Currently (Servers/Networks Are Not My Strong Area)
Apache 3 on CentOS 6.8
Default PHP Version | 5
PHP 5 Handler | suPHP
Apache suEXEC | off
Apache Ruid2 | off
Default PHP Version (.php files) | 5
PHP 5 Handler | suPHP
Attempted Solutions
Disabled .htaccess
.htaccess contains
***suPHP_ConfigPath /***
Header append Vary User-Agent
Prior to disabling:
Removed All 301 Rewrite Rules as I've read they interfere with
sessions
Disabled Error Documents
Ensure No Whitespaces Following session_start();
Caching
Turned off all caching through WHM (that I'm aware of)
Tested both Firefox and Chrome before and after clearing history/cookies/cache/etc
Deleted CloudFlare service for this domain
Additional Information
I Don't have a php.ini file since I use a VPS (in case anyone was wondering)
I use php on almost every other page.
Here is an example of the first few lines of another page.
<?php
session_start();
$ip = $_SERVER['REMOTE_ADDR'];
//Version 1.75
The above code is just the first few lines but the page executes fine without issue. It should be noted that this is a redirect page following a PayPal payment to my website. This issue is recent and previously it has worked fine.
It should also be noted that I use session_write_close(): session_unset(); and session_destroy(); on appropriate pages to unset all $_SESSION variables and terminate sessions.
Below is a link to the php.ini file as text if that helps. The domain contained in the link is not the domain with the issue. I'm not attempting to be "shifty" about the domain with the issue, I just don't want people using the service when it's not working properly.
Global PHP INI File As Text Document
Anyone who solves this, I owe you!
-Andrew
Solved Accidentally
I solved the issues, but still don't know what was causing the Fatal Error
Fatal error: Can't use function return value in write on line 3
$_SESSION variables didn't pass between pages.
I solved both the Fatal Error issue and the $_SESSION variables problem by doing one thing. For some, this may be standard procedure, but I am self-taught and this did not occur to me. I was making changes to the PHP advanced configuration in WHM and never did not see any changes as a result.
I was banging my head against the wall for two days trying every solution I read in the forums.
Apache Server Restart
I never restarted my Apache Server during this time, both issues were resolved.
While this solution may seem rudimentary or common practice for some, it's easy to overlook. I read at least 30 different forum posts on Stack Overflow and other sites. Not one suggested an Apache Restart as a method to check.
PHP Configuration
I changed my PHP configuration as listed below and my sessions variables were passing.
session.use_cookies = 1
session.use_only_cookies = 1
session.use_trans_sid = 0
Thank you for everyone who took the time to look at this.
Sincerely, Andrew

using stream wrappers in php gives blank page

I am implementing a template system using the wrapper class in this example: http://www.php.net/manual/en/stream.streamwrapper.example-1.php
I use this code to get the wrapper output:
ob_start();
include("template://" . $template_name);
$template .= ob_get_contents();
ob_end_clean();
However, in some servers this code is not working, all I get is a blank page. I am not sure if it is a php directive issue, I changed allow_url_include to both 0 and 1, but it did not have any effects on the code.
So what is the problem with the code.
EDIT: error logging is on, and it is not showing any errors related to this issue
in some servers this code is not working
In all likelihood, this is because php streams are not available or configured properly on these servers. It die with an error, and you don't see the error because of the output buffer
My host updated to Litespeed and a more stringent Suhosin setup. At first I thought it was Litespeed, but it was indeed Suhosin (I twigged from this thread, thanks!).
It's just a php.ini setting you need to change, you have to add your stream name to the include whitelist:
suhosin.executor.include.whitelist = template://
And then it'll work fine again. Here's a couple more links saying the same:
A bigger example: http://cweiske.de/tagebuch/suhosin-phar.htm
-Others struggling with the same: http://forum.bytesforall.com/showthread.php?t=12262&page=2
Suhosin doco (doesn't really explain with huge detail) search for: suhosin.executor.include.whitelist
I had the same issue and found that PHP Suhosin was causing this 'white screen of death'.
That could explain why this works on some servers and not on others.
There could be a Suhosin config option for dealing with that, check out the website: http://www.hardened-php.net/suhosin/
tl;dr I ended up removing Suhosin which resolved the issue.

Error message: "unexpected termination of script, debugging ended", when debugging PHP with Xdebug and Eclipse

I'm getting the following error when debugging:
php.ini settings:
xdebug.remote_enable=true
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
Assuming no syntax errors, make sure that you do not have any watches that cause the script to crash as the debugger attempts to evaluate them.
From my experience, this is the most common cause for such early death.
Regardless of that, you may also wish to change your internal web browser, as IE tends to provide cryptic error messages, or use an external browser session (and use remote debugging).
removing watch expressions solved this issue for me
If you are using mod_fcgid in your apache
the default value which is set for FcgidIOTimeout is 40 seconds so you get this xdebug to terminate in 40 seconds
to changed this value you need add the following line in you apache httpd.conf file
FcgidIOTimeout 600
this is for 10 minutes you can set this value to any other time limit according your requirement
even i had the same problem i found this solution for further details follow the links below
http://jonathonhill.net/2011-05-05/uploading-large-files/ (related link which gives info about the value)
http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html ( and search for FcgidIOTimeout)
I ran into the same issue on a different platform.
Running x64 linux with Eclipse 3.7.2, PHP 5.4.3 and Xdebug 2.2.0, this error message may appear when viewing variables.
See Xorg issue #797 and issue #824.
I can confirm that this issue is not resolved in release 2.2.0. The resolution is committed after 2.2.0, so you'll have to download a git copy (check the download page).
After compiling the git version, the issue at hand is resolved.
I also got this problem, after Googling for awhile I decided to revert back to 2.2rc because it's the latest version that this issue does not occur (actually not "always" but "sometimes", just need to relaunch).
Before that I've tried 2.3dev too with no luck.

Frequent "Connection Timeout" errors on a shared server using PHP/MYSQL

I have a Drupal site on a shared web host, and it's getting a lot of connection errors. It's the first time I have seen so many connection timeout errors on a server. I'm thinking it's something in the configuration settings. Non-drupal parts of the site are not giving as many connection errors.
Since this hosting provider doesn't give me access to the php.ini file, I put one at my docroot to modify the lines that I thought would be causing this:
memory_limit = 128M
max_execution_time = 259200
set_time_limit = 30000
But it didn't work. There is no improvement in the frequency of the timeout errors. Does anyone have any other ideas about this type of error?
Thanks.
You can control the time limit on a script while your script is running. Add a called to set_time_limit near the top of your PHP pages to see if it helps.
Ideally you need to figure out what you actual limits are as defined by your host. A call to phpinfo() somewhere will let you see all the config settings that your server has in place.

wamp cannot load mysqli extension

WAMP installed fine, no problems, BUT...
When going to phpMyAdmin, I get the error from phpMyAdmin as follows:
Cannot load mysqli extension. Please check your PHP configuration
Also, phpMyAdmin documentation explains this error message as follows:
To connect to a MySQL server, PHP needs a set of MySQL functions
called "MySQL extension". This extension may be part of the PHP
distribution (compiled-in), otherwise it needs to be loaded
dynamically. Its name is probably mysql.so or php_mysql.dll.
phpMyAdmin tried to load the extension but failed. Usually, the
problem is solved by installing a software package called "PHP-MySQL"
or something similar.
Finally, the apache_error.log file has the following PHP warnings (see the mySQL warning):
PHP Warning: Zend Optimizer does not support this version of PHP - please upgrade to the latest version of Zend Optimizer in Unknown on line 0
PHP Warning: Zend Platform does not support this version of PHP - please upgrade to the latest version of Zend Platform in Unknown on line 0
PHP Warning: Zend Debug Server does not support this version of PHP - please upgrade to the latest version of Zend Debug Server in Unknown on line 0
PHP Warning: gd wrapper does not support this version of PHP - please upgrade to the latest version of gd wrapper in Unknown on line 0
PHP Warning: java wrapper does not support this version of PHP - please upgrade to the latest version of java wrapper in Unknown on line 0
PHP Warning: mysql wrapper does not support this version of PHP - please upgrade to the latest version of mysql wrapper in Unknown on line 0
So, for some reason PHP is not recognizing the mysql extension.
Anyone know why? Any solution or workaround?
I deleted the PHP in program files ad everything started working , the problem that there two installations of pHp
I tried many solutions, and none worked for me. I tried the following solutions:
Restart wampserver
Reinstall wampserver
restart machine
and all other solutions mentioned in this question.
However, none of these worked. Then I found that my PHPMyAdmin was not working in chrome and was working in firefox. So I tried clearing cache, restarting browser etc, but still it would not work.
Then I deleted all the files from C:\wamp\tmp and then tried again, and it works. I am not sure why it works, but here is what I think. The session was cached and not getting cleared. So as soon as I deleted all files in this directory all the sessions were deleted and hence it worked fine.
First, make sure that the php.ini file is loading the mysqli extension.
If you are using WAMPServer, click on the icon in the system tray, go to PHP -> PHP Extensions and make sure it is checked. If not, go into the php.ini file and make sure that the line: extension=php_mysqli.dll is uncommented (eg, remove the ; if it exists). If that line does not exist, add it.
If this still does not work, double check that the right php.ini file is being loaded.
To do so, view your phpinfo() (Here for WAMPServer). Scroll down to the Loaded Configuration File row and see which php.ini is being loaded.Make sure it is the right file. If you're using WAMPServer, it should be(WAMP INSTALL FOLDER)\bin\apache\Apache2.2.11\bin\php.ini. By default, it isC:\wamp\bin\apache\Apache2.2.11\bin\php.ini`.
If a different php.ini file is being loaded, just rename it to something else so that PHP will try and find the file somewhere else. There should be a way to specify which on eyou want to use, but I forget exactly how to do that...
If this still doesn't work... Try messing around with phpMyAdmin's settings, or using another answer, but I'm afraid I can't help beyond this.
I was running WAMP with two PHP versions 1) 5.2.9 and 2) 5.2.13.
As per site requirement i needed to change PHP version to 5.2.9 from 5.2.13. after swapping PHP version, error was "mysqli extension is missing". after debugging long time i get to know it was due to wrong "extension_dir" path in php.ini file.
So i changed its value:
Old: "extension_dir" c:/wamp/bin/php/php5.2.13/ext/
New: "extension_dir" c:/wamp/bin/php/php5.2.9/ext/
Restarted All services in wamp server, then it's fixed.
I had the same problem. I had WAMP server installed. All was working fine. Then one day I restarted my computer and it just stopped working! I tried desperately going through all help posts and doing them but nothing worked.
What they usually suggest you do is, first go to your php.ini file and make sure your 'extension_dir' is properly set. Then to make sure these two lines are not commented (remove the ; infront):
extension=php_mysql.dll
extension=php_mysqli.dll
Then some suggested that I download fresh copies of these two files but none worked. I also tried uninstalling everything (php/mysql/apache) and reinstalled fresh copies of WAMP server several times but with no luck.
Finally I managed to find an alternative solution. I switched to 'easyphp' (http://www.easyphp.org/). This is something very similar to WAMP. First I made backups of my sql databases so I can reload them on the new installation.
Then I installed 'easyphp' and everything seems to work fine. I reloaded my sql databases from my backup and now things are back to normal.
I hope someone suffering from a similar prob. will find this useful. If someone has really found a fix to make WAMP server work. Pls do be kind enough to post it here so many will benefit.
in wampserver go to php.ini. open the file and uncomment extension=msql.dll by removing semicolon(;) for respective operating sytem.
Just add in your php.ini:
[PHP_MCRYPT]
extension=php_mcrypt.dll
[PHP_MYSQL]
extension=php_mysql.dll
[PHP_MYSQLI]
extension=php_mysqli.dll
Also setup the mysql password:
SET PASSWORD FOR root#localhost=PASSWORD('your_password');
And the phpmyadmin mysql password in config.inc.php:
$cfg['Servers'][$i]['password'] = 'your_password';
Had the same problem, with wamp. Try to exchange your current version of php.ini with a backup. There is one in: wamp\bin\php\php5.3.0phpForApache.txt. Worked for me.
Just wanted to chime in on this one. Using Wamp Server 2.0, and using Zend Studio with Zend debugger for development.
I wasn't able as of yet (will get back to it at some point) to get the zend debugger working with php 5.3. So in wamp I loaded an earlier php version, 5.2.11. I was getting the same error when acessing php my admin.
What I had to do was change the php.ini file value for "extension_dir" to c:/wamp/bin/php/php5.2.11/ext/ to match the version of php I was using. After that it was all good.
I had this problem and spent 2 hours trying all the solutions online, none worked.
Tried this, and it woked:
Change
mysql.default_host =
to
mysql.default_host = localhost
and restart WAMP. pay attention if you are using mysqli or not.
I had the same error. When I increased the script memory size and enabled E_ALL then restarted the server, I got that error in phpmyadmin. All I had to do to fix it was restart my computer!
I got this problem for a long time. Tried all I've read on forums and this finally worked for me:
Open your php.ini (I assume you've got the good one that is loaded...) and find this line
mysqli.default_port = 3306
change for
mysqli.default_port = 80
Restart all services
Go to localhost/phpmyadmin -> won't work
Reopen the php.ini file and retype this
mysqli.default_port = 3306
Restart all services
Worked for me.
For me worked this, after searching all logs/internet/every non-normal things.
You have to register dl by:
Through application:
WAMP -> PHP settings -> enable dl
or
# php.ini #
; Whether or not to enable the dl() function. The dl() function does NOT work
; properly in multithreaded servers, such as IIS or Zeus, and is automatically
; disabled on them.
; http://php.net/enable-dl
enable_dl = On
I have just installed WampServer, and faced same problem. I have found solution, that works for me, it is ridiculously simple.
Disable PHP extension php_mysqli.
Restart WampServer, visit local phpmyadmin.
Enable php_mysqli back.
Repeat step 2.
After few page refreshes, remaining errors plates (about MySQL and sqli) had gone.
i tried hard by
installing the wamp again and again,
by checking the php.ini file,
by restarting the machine,
by replacing the index.php file,
but none works.
then i go to the wamp/temp and deleted all files and it works fine now.
I had path variable in windows set to some random version of php.
The fix was to update it and set it to the folder within my wampserver installation:
C:\wamp64\bin\php\php5.6.38
Then I realized this is wrong also for my specific case, and I should actually be running the script from within vagrant. Live and learn.
I had this issue because of a different reason:
Check the PHP Error Log(Get from the Wamp Tray -> PHP -> PHP Error Log.
I had a syntax error in the php.ini file while I was editing the file.
Check the log and clear the error. This will open your PhpMyAdmin properly.
Check your phpForApache.ini file's extensions. This file should be same as your php.ini file.

Categories