logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: PHP 7.1.16 VirtualAlloc() errors dying for memory
Author
sam452



Joined: 19 Dec 2016
Posts: 23
Location: US, Nashville

PostPosted: Wed 11 Apr '18 0:37    Post subject: PHP 7.1.16 VirtualAlloc() errors dying for memory Reply with quote

I have a decent Drupal 7 site running on Windows 2008 r2 server with 4 gigs of RAM. I installed the ApacheLounge version of Apache 2.4 a couple of years ago and ran it with PHP 5.6 and has not been a problem.
I updated the custom code to run correctly on PHP 7.1 locally and downloaded a fresh copy of php-7.1.16-Win32-VC14-x86 from php.net carefully choosing the x86, thread-safe version, which should align with my Apache
Windows NT MED-IISV1 6.1 build 7601 (Windows Server 2008 R2 Standard Edition Service Pack 1) i586
MSVC14 (Visual C++ 2015)
x86
Looking at my working php.ini I was careful to rename the production version of php.ini as php.ini and copying over the environment values, such as memory_limit of 156M, where my php error logs should reside, etc. Also because this is Server 2008 I set up the version 3 Sql_server PHP drivers and they seem to work the the site is up.
I've increased the php memory_limit up to 500M and values in between but still get downtime. The Apache logs return many lines of
Code:
VirtualAlloc() failed: [0x00000008] Not enough storage is available to process this command.

I used thread safe because I could not see any way to align PHP with Apache without the php7_apache.2.4.dll which does not exist with NTS PHP.
I think the apache errors are reactions to PHP running out of memory. Reading online, I see that some suggest PHP scripts may be poorly written and gobble up memory. I doubt that in this case because the PHP errors point to normal operations in the very latest in Drupal 7 code which has never been the problem. Like this example:
Code:
PHP Fatal error:  Out of memory (allocated 2097152) (tried to allocate 28672 bytes) in C:\Server\modules\system\system.tokens.inc

Looking at the MPM this Apache is using I see that it's using the default mpm_winnt.c
Code:
<IfModule mpm_winnt_module>
    ThreadsPerChild        150
    MaxConnectionsPerChild   0
</IfModule>

I see the two variables it's looking for, but after reading the docs on mpm_winnt I'm trying to determine the relationship between php memory_limit and apache MPM and its threads.
Perhaps you can point out my false assumptions about matching up this architecture and this PHP install. But other than these memory crashes, everything on this app seems to be running well, including the SQL server PHP drivers. But I'm hoping to get someone's eyes on this set of circumstances and perhaps point me to what I'm overlooking in this setup. Thx.[/code]
Back to top
Jan-E



Joined: 09 Mar 2012
Posts: 1248
Location: Amsterdam, NL, EU

PostPosted: Wed 11 Apr '18 8:39    Post subject: Reply with quote

The thread-safe versions of PHP 7.0 and PHP 7.1 are broken:
https://www.apachelounge.com/viewtopic.php?p=36139#36139

Best option for Drupal 7: switch to PHP 7.1 NTS and run it using mod_fcgid. My testserver is Win 2008 R2 with 4GB RAM and it is running fine with a PHP memory_limit of 768M.
Back to top
sam452



Joined: 19 Dec 2016
Posts: 23
Location: US, Nashville

PostPosted: Wed 11 Apr '18 18:23    Post subject: Reply with quote

Thank you for offering that. I will do so, but I have not seen how PHP ties in with Apache on Windows. In thread-safe it's explicit, but I fail to see why on non-thread-safe PHP?
Back to top
sam452



Joined: 19 Dec 2016
Posts: 23
Location: US, Nashville

PostPosted: Thu 12 Apr '18 5:34    Post subject: Reply with quote

Jan-E wrote:

Best option for Drupal 7: switch to PHP 7.1 NTS and run it using mod_fcgid. My testserver is Win 2008 R2 with 4GB RAM and it is running fine with a PHP memory_limit of 768M.


Thank you, I believe I'm pretty close. As you read above, Drupal 7 was being served by PHP 5.6, and with crashes PHP 7.1 ts. Your pointer to mod_fcgid is key. Following the instructions in its READ ME I copied the 32-bit version of the module, copied the config files and placed them at the end of my httpd.conf file and restarted.
What's frustrating is that every Drupal page of this formerly working site returns a 403.
The Apache error log for this app only shows where I restarted Apache24. Nothing that would indicate why I'm getting 403. The access logs show 403 for every request.
Reading online, I'm seeing what Directory directives should be in place. I've gone through this already, but here's what was working and is not working now. This excerpt from httpd.conf

Code:
<Directory />
    Options FollowSymLinks
    AllowOverride All
    Order deny,allow
    Deny from all
</Directory>


Code:
DocumentRoot "c:/Server/DM"
<Directory "c:/Server/DM">
   Options  FollowSymLinks
   AllowOverride All
   Allow from all
    Require all granted
</Directory>


My working extra/httpd-vhosts.conf

Code:
<VirtualHost *:8080>
    DocumentRoot "C:/Server/uat"
    ServerName uat-dm.org
    ErrorLog c:/Apache24/logs/uat-error.log
    CustomLog c:/Apache24/logs/uat-access.log common
   <Directory "C:/Server/uat">
      Options FollowSymlinks
      AllowOverride All
     Allow from all
      Require all granted
    </Directory>
</VirtualHost>


What am I missing? thx, sam[/code]
Back to top
Jan-E



Joined: 09 Mar 2012
Posts: 1248
Location: Amsterdam, NL, EU

PostPosted: Thu 12 Apr '18 6:37    Post subject: Reply with quote

Try adding

Code:
<Directory "c:/php71">
    AllowOverride All
    Allow from all
    Require all granted
</Directory>

For wherever you installed php71. Put this before the fcgid_module directives.
Back to top
sam452



Joined: 19 Dec 2016
Posts: 23
Location: US, Nashville

PostPosted: Thu 12 Apr '18 13:07    Post subject: Not there yet Reply with quote

Thank you very much for replying. I wouldn't have thought of that.
However, adding this directive before the fcgid did not make any apparent difference after restarting apache 2.4.
I have verified that php runs in the CLI.

I have experimented with putting these directives at the end, after the AddHandler. Also tried commenting out the AddHandler, AddType after restarting to see if I can get movement. Still nothing yet.

Additional directives:

Code:
<Directory "C:/php-7.1.16-NTS-Win32-VC14-x86">
    AllowOverride All
   Allow from all
   Require all granted
</Directory>


Here's my fcgid.


Code:

AddHandler application/x-httpd-php .php
AddType application/x-httpd-php .php .html
#these have failed because we're using mod_fcgid and are removed
#LoadModule php7_module C:\php-7.1.15-Win32-VC14-x86\php7apache2_4.dll
#PHPIniDir "C:\php-7.1.16-NTS-Win32-VC14-x86"
SSLSessionCache "shmcb:logs/ssl_scache(512000)"

FcgidInitialEnv PATH "c:/php-7.1.16-NTS-Win32-VC14-x86;C:/WINDOWS/system32;C:/WINDOWS;C:/WINDOWS/System32/Wbem;"
FcgidInitialEnv SystemRoot "C:/Windows"
FcgidInitialEnv SystemDrive "C:"
FcgidInitialEnv TEMP "C:/WINDOWS/Temp"
FcgidInitialEnv TMP "C:/WINDOWS/Temp"
FcgidInitialEnv windir "C:/WINDOWS"
FcgidIOTimeout 64
FcgidConnectTimeout 16
FcgidMaxRequestsPerProcess 1000
FcgidMaxProcesses 50
FcgidMaxRequestLen 8131072
# Location php.ini:
FcgidInitialEnv PHPRC "c:/php-7.1.16-NTS-Win32-VC14-x86"
FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 1000

<Files ~ "\.php$>"
  AddHandler fcgid-script .php
  FcgidWrapper "c:/php-7.1.16-NTS-Win32-VC14-x86/php-cgi.exe" .php
</Files>

Back to top
sam452



Joined: 19 Dec 2016
Posts: 23
Location: US, Nashville

PostPosted: Mon 16 Apr '18 21:07    Post subject: updated fcgid Reply with quote

Looking for an example usage of mod_fcgi in Apache 2.4 I wanted to leave what appears to be working with PHP 7.1.16 NTS in case anyone searching. I adapted from another post on apache lounge this result. Would love to have advice on tweaking this.

Code:

SSLSessionCache "shmcb:logs/ssl_scache(512000)"

<IfModule fcgid_module>
   FcgidMaxProcesses 300
   FcgidMaxProcessesPerClass 300

   FcgidOutputBufferSize 65536
   FcgidConnectTimeout 10
   FcgidProcessLifeTime 0
   FcgidMaxRequestsPerProcess 0
   FcgidMinProcessesPerClass 0
   FcgidFixPathinfo 0
   FcgidProcessLifeTime 0
   FcgidZombieScanInterval 20
   FcgidMaxRequestLen 536870912
   FcgidIOTimeout 110
   FcgidTimeScore 3

   FcgidPassHeader Authorization

   FcgidInitialEnv PHPRC "C:\php-7.1.16-NTS-Win32-VC14-x86"
   FcgidInitialEnv PATH "C:\php-7.1.16-NTS-Win32-VC14-x86;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;"
   FcgidInitialEnv SystemRoot "C:\\Windows"
   FcgidInitialEnv SystemDrive "C:"

   FcgidInitialEnv TEMP "C:\\WINDOWS\\TEMP"
   FcgidInitialEnv TMP "C:\\WINDOWS\\TEMP"
   FcgidInitialEnv windir "C:\\WINDOWS"

   DefaultInitEnv PHPRC "C:/php-7.1.16-NTS-Win32-VC14-x86"
   DefaultInitEnv PATH "C:/php-7.1.16-NTS-Win32-VC14-x86;C:/Apache24/bin;C:/WINDOWS/system32"

   
   <Files ~ "\.php$">
      Options Indexes FollowSymLinks ExecCGI
      AddHandler fcgid-script .php
      FcgidWrapper "C:/php-7.1.16-NTS-Win32-VC14-x86/php-cgi.exe" .php
   </Files>
</IfModule>

I removed the directive for the PHP folder. [/code]
Back to top
eggsurplus



Joined: 19 Jul 2018
Posts: 1

PostPosted: Thu 19 Jul '18 18:08    Post subject: VirtualAlloc() failed Reply with quote

We are running into the same issue as sam452 with PHP 7.2.7 and 7.2.8 (TS).

Is this still a known issue with thread safe PHP?

Current setup:

Windows Server 2008 R2 Standard (64bit)
Apache 2.4.34 (32bit)
PHP 7.2.8 (php-7.2.8-Win32-VC15-x86.zip)
msphpsql 5.2.0 driver

After a few hours we start running into:

VirtualAlloc() failed: [0x00000008] Not enough storage is available to process this command.
VirtualFree() failed: [0x000001e7] Attempt to access invalid address.

A restart temporarily makes it go away.

Any insight or help would be greatly appreciated.

Meanwhile, will try a NTS install on a test server.
Back to top
Jan-E



Joined: 09 Mar 2012
Posts: 1248
Location: Amsterdam, NL, EU

PostPosted: Thu 19 Jul '18 20:41    Post subject: Reply with quote

PHP 7.2 TS does not have any known problems. The issue was for 7.0 and 7.1 TS.
Back to top


Reply to topic   Topic: PHP 7.1.16 VirtualAlloc() errors dying for memory View previous topic :: View next topic
Post new topic   Forum Index -> Apache