mod-fcgid interview questions
Top mod-fcgid frequently asked interview questions
I'm installing Apache 2.4.7 with PHP5 and I use fcgid and suexec.
I read that some people use PHP-FPM with fastcgi, but I don't know if they are speaking about the old fastcgi or the new fcgid.
Anyway, I want to know if my configuration of fcgid without PHP-FPM is correct or I need to install and configure PHP-FPM to have all the functionality?
Which is the advantage and disadvantage of putting fcgid and PHP-FPM together, in the case that it is correct?
Source: (StackOverflow)
A page is resulting in a 500 error and the log shows this:
[Wed Mar 20 11:19:23 2013] [warn] [client 127.0.0.1] (104)Connection reset by peer: mod_fcgid: ap_pass_brigade failed in handle_request_ipc function
It is occuring on a lemonstand website, when you try to view 90 products on a category page. The step from 60 per page to 90 appears to be too many, and it results in a 500 error.
The page loads for no more than around 4 seconds before the error, and there are many other websites running on the server which do not experience this issue.
I have so far assumed that this is due to environment settings, and not caused by Lemonstand. I have googled the heck out of this and tried various config settings to get it to behave, none have so far fixed it. Below is the current fcgid config, I have commented out some of the variables I tried changing.
Fcgid.conf:
<IfModule mod_fcgid.c>
AddHandler php-fcgi .php
Action php-fcgi /fcgi-bin/php-fcgi-wrapper
AddType application/x-httpd-php .php
Alias /fcgi-bin/ /var/apache/fcgi-bin/
FcgidConnectTimeout 180
FcgidIOTimeout 600
FcgidBusyTimeout 3600
FcgidMaxRequestLen 226777216
FcgidFixPathinfo 1
#FcgidOutputBufferSize 65536
#FcgidProcessLifeTime 30
#FcgidMaxRequestsPerProcess 500
FcgidIdleTimeout 60
#FcgidIdleScanInterval 1
#FcgidBusyTimeout 60
#FcgidBusyScanInterval 1
#FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 100000
<Location /fcgi-bin/>
SetHandler fcgid-script
Options +ExecCGI
Order allow,deny
Allow from all
</Location>
</IfModule>
Source: (StackOverflow)
I am trying to configure the Python mini-framework CherryPy with FastCGI (actually fcgid) on Apache. I am on a shared host, so I don't have access to httpd.conf, just htaccess. I have followed these tutorials to no avail:
I keep getting 500 errors w/ the Apache logs saying "Premature end of script headers". I have tried everything (permissions/shebangs/full-paths/deamonized/not-daimonized). I know Apache is correctly executing my .fcgi, because I am able to print to the error log from python, but that's it. Has anyone out there successfully installed CherryPy or any other framework on a shared host before? Your help would be greatly appreciated. Thanks.
Source: (StackOverflow)
I have implementing a program that using lighttp web server and fcgi(c script).
And I have searched many times but don't find any page guide to do this. Just setting lighttpd and python fcgi or php fcgi... but C fcgi.
Can anyone help me to configure lighttpd and c fcgi?
Many thanks.
I have wrote a sample as below, and build it to executable file. But now I don't know how to run it with lighttpd web server.
#include "fcgi_stdio.h"
#include <stdlib.h>
#include <stdio.h>
int count;
using namespace std;
void initialize(void)
{
count=0;
}
int main(void)
{
/* Initialization. */
initialize();
/* Response loop. */
while (FCGI_Accept() >= 0) {
printf("Content-type: text/html\r\n"
"\r\n"
"<title>FastCGI Hello! (C, fcgi_stdio library)</title>"
"<h1>FastCGI Hello! (C, fcgi_stdio library)</h1>"
"Request number %d running on host <i>%s</i>\n",
++count, getenv("SERVER_HOSTNAME"));
}
return 0;
}
Source: (StackOverflow)
I am having troubles with the current apache httpd (2.2.21) and mod_fcgid (2.3.6) versions. In my project, it is possible that the ScriptAlias directive in the httpd.conf can contain spaces because operating system paths can contain them. This use to work with older httpd and fcgid versions. But since we switched to the current versions, it doesn't work anymore. If the path of the ScriptAlias contain a space and mod_fcgid wants to start my fcgi process, I get the following error log:
326 [Fri Jan 06 11:30:01 2012] [notice] Apache/2.2.21 (Unix) mod_fcgid/2.3.6 configured -- resuming normal operations
327 [Fri Jan 06 11:30:03 2012] [warn] [client 77.58.246.206] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
328 [Fri Jan 06 11:30:03 2012] [error] [client 77.58.246.206] Premature end of script headers: somename.fcgi
Is this a known problem? I couldn't find anything on Google.
Best
David
Source: (StackOverflow)
I have a php script that loads a webpage from a url passed from the client, parses it and sends results to the client.
When running on my development environment (laptop with windows 7 & wamp installed), it works perfectly, but when uploaded to the server (windows server 2008 R2 + php 5.3.6 + apache 2.2 + mod_fcgid 2.3.9), running it results with an "Internal Server Error".
I can see how the FastCGI process, handling the request, memory consumption rises up to a point where it gets suspended and terminates unexpectedly.
The apache error log shows these 2 messages:
(OS 109)The pipe has been ended. : mod_fcgid: get overlap result error, referer: http://some_domain.com/NL-Analysis/getDomainResults
(OS 109)The pipe has been ended. : mod_fcgid: ap_pass_brigade failed in handle_request_ipc function, referer: http://some_domain.com/NL-Analysis/getDomainResults
I've tried finding solutions on the internet based on the error log, most of what I found pointed me to the mod_fcgid configurations.
I've tried to change some of the mod_fcgid directives and limits, but it didn't help.
Currently the mod_fcgid is configures with these parameters in httpd.conf:
FcgidInitialEnv PHP_FCGI_MAX_REQUESTS=1000
FcgidIOTimeout 7200
FcgidConnectTimeout 7200
FcgidBusyScanInterval 7200
FcgidBusyTimeout 7200
FcgidMaxRequestsPerProcess 1000
FcgidMaxProcesses 80
FcgidIdleTimeout 7200
FcgidMaxRequestInMem 100000000000
FcgidProcessLifeTime 7200
I will be happy to provide any other inputs.
Can anybody think of a way to prevent the FastCGI process from terminating?
Thanks,
Alon.
Source: (StackOverflow)
I am get this error when request a page that the application try to get data from database:
mod_fcgid: stderr: PHP Fatal error: Class 'Doctrine\\DBAL\\Platforms\\AbstractPlatform' not found in /var/www/vhosts/jonesandsacristan.es/httpdocs/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php on line 38
Its is running on debian
with
PHP 5.4.34-0+deb7u1 (cli) (built: Oct 20 2014 08:50:30)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
with the ionCube PHP Loader v4.6.0, Copyright (c) 2002-2014, by ionCube Ltd.
Do anyone can help me?
Source: (StackOverflow)
update: Just looked at the cache update times of long queries and they did not collide with server crash time.
update2: Found the cause of the problem. Ad server is down and the server hangs even though it seems we set socket timeouts properly. Is there any way to test timeout behaviour?
We have a very busy server. ~3K concurrent connections
The server has 32GB ram 2xCPUs. We have service unavailable error issues.
The server does not respond with 500 error and the error log shows hundreds/thousands of lines:
[warn] mod_fcgid: can't apply process slot for /var/www/fcgi-bin.d/php5-default/php-fcgi-wrapper
We think it can be a configuration error or a database connection/query error.
A php process updates a cache which is a very very complex query result. 3 separate queries run each twice a day. I have enabled the slow query log. I suspect if the query exceeds the php run time limit 20 secs in our case (set in the following files). Any help is appreciated.
We use apache worker mpm model with mod_fcgid.
Here is fcgid.conf file:
<IfModule mod_fcgid.c>
AddHandler fcgid-script .fcgi
SocketPath /var/lib/apache2/fcgid/sock
# Communication timeout: Default value is 20 seconds
IPCCommTimeout 20
# Connection timeout: Default value is 3 seconds
IPCConnectTimeout 3
And /etc/apache2/conf.d/php-fcgid.conf file:
<IfModule !mod_php4.c>
# Path to php.ini <96> defaults to /etc/phpX/cgi
DefaultInitEnv PHPRC=/etc/php5/cgi
# Number of PHP childs that will be launched. Leave undefined to let PHP decide.
# DefaultInitEnv PHP_FCGI_CHILDREN 8
# Maximum requests before a process is stopped and a new one is launched
DefaultInitEnv PHP_FCGI_MAX_REQUESTS 5000
# Maximum requests a process handles before it is terminated
MaxRequestsPerProcess 1500
# Maximum number of PHP processes.
MaxProcessCount 45
# Define a new handler "php-fcgi" for ".php" files, plus the action that must follow
AddHandler php-fcgi .php
Action php-fcgi /fcgi-bin/php-fcgi-wrapper
# Define the MIME-Type for ".php" files
AddType application/x-httpd-php .php
# Define alias "/fcgi-bin/". The action above is using this value, which means that
# you could run another "php5-cgi" command by just changing this alias
Alias /fcgi-bin/ /var/www/fcgi-bin.d/php5-default/
# Turn on the fcgid-script handler for all files within the alias "/fcgi-bin/"
<Location /fcgi-bin/>
SetHandler fcgid-script
Options +ExecCGI
</Location>
Apache2 worker mpm config:
<IfModule mpm_worker_module>
StartServers 10
MaxClients 2048
ServerLimit 2048
MinSpareThreads 30
MaxSpareThreads 100
ThreadsPerChild 64
ThreadLimit 100
MaxRequestsPerChild 5000
We looked at the instructions on this web page and loaded high server config:
http://2bits.com/articles/apache-fcgid-acceptable-performance-and-better-resource-utilization.html
update: Just looked at the cache update times of long queries and they did not collide with server crash time.
update2: Found the cause of the problem. Ad server is down and the server hangs even though it seems we set socket timeouts properly. Is there any way to test timeout behaviour?
Source: (StackOverflow)
I've been trying to set up trac to be deployed with apache for a little while now and I'm running into a wall.
I can get it to work via tracd but I'm probably going to have multiple projects and I might want to use TSL for connections to trac.
This is the response I'm receiving from my server
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Apache/2.2.14 (Ubuntu) Server at ***.***.***.*** Port 80
This is my apache v-host file: (Comments removed)
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DirectoryIndex index.html
DocumentRoot /home/***/public_html/app/public
Alias /trac/chrome/common /home/***/trac/htdocs/common
Alias /trac/chrome/site /home/***/trac/htdocs/common
ScriptAlias /trac /home/***/trac/cgi-bin/trac.fcgi/
DefaultInitEnv TRAC_ENV /home/***/trac
<Location "/trac">
SetEnv TRAC_ENV_PARENT_DIR "home/***/"
</Location>
<Directory "/home/***/trac/htdocs">
Order allow,deny
Allow from all
</Directory>
<Location "/trac/chrome/common">
SetHandler none
</Location>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /home/***/public_html/app/log/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel debug
CustomLog /home/***/public_html/app/log/access.log combined
CustomLog /home/casey/public_html/app/log/access.log combined
</VirtualHost>
And this is my server's error log:
[Fri Apr 29 02:09:06 2011] [warn] [client **.**.**.**] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Fri Apr 29 02:09:06 2011] [error] [client **.**.**.**] Premature end of script headers: trac.fcgi
[Fri Apr 29 02:09:06 2011] [debug] mod_deflate.c(615): [client **.**.**.**] Zlib: Compressed 618 to 384 : URL /trac/
[Fri Apr 29 02:09:08 2011] [warn] [client **.**.**.**] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Fri Apr 29 02:09:08 2011] [error] [client **.**.**.**] Premature end of script headers: trac.fcgi
[Fri Apr 29 02:09:08 2011] [debug] mod_deflate.c(615): [client **.**.**.**] Zlib: Compressed 618 to 384 : URL /trac/
Does anyone know what might be going on and what I should do to fix it? Thanks!
Source: (StackOverflow)
I have an issue with a URL my application is trying to access timing out. I am trying to catch this timeout and to solve this problem am using this code:
$timeout = 120;
if(false == $handle = @fsockopen($host, $port, $errno, $errstr, $timeout))
{
throw new Exception("Could not connect to url: ".$errstr);
}
$getRequest = "GET {$url} HTTP/1.0\r\n";
$getRequest .= "Host: {$urlParts['host']}\r\n";
$getRequest .= "Connection: close\r\n\r\n";
fwrite($handle, $getRequest);
$maxExecutionTime = ini_get('max_execution_time');
set_time_limit($timeout+10);
stream_set_timeout($handle, $timeout);
$head = fread($handle, 1024); // Read the first 1024 bytes
if($maxExecutionTime == 0) {
$maxExecutionTime = 30;
}
set_time_limit($maxExecutionTime);
$stream_metadata = stream_get_meta_data($handle);
if($stream_metadata['timed_out'] === true) {
throw new Exception("Connection timed out");
}
My URL I am using for the timeout is behind a firewall, so I can not share it, but it is designed to sleep() for 5 minutes. When I try to run this code, execution stops at $head = fread($handle, 1024); and after 90 seconds I get a 500 error from the server "Premature end of script". When I investigate at the debug level in the apache logs I see:
[Fri Aug 26 11:10:45 2011] [warn] [client 192.168.10.202] mod_fcgid: read timeout from pipe
[Fri Aug 26 11:10:45 2011] [error] [client 192.168.10.202] Premature end of script headers: validateUrl.php
with 'validateUrl.php' being the url I am accessing this script through. I'm not sure increasing FcgidIOTimeout to a higher value is safe, as it would apply to all of my pages. Any ideas/ comments?
System details:
PHP Version 5.2.13 running on Windows NT EPG-WEB 5.2 build 3790
Apache: Apache/2.2.19 (Win32) mod_fcgid/2.3.6
Source: (StackOverflow)
I recently changed the webserver environment on my production system to Apache2.4/mod_fcgid 2.3.9. On restarting Apache, I realized that my scripts depending on the PHP getenv()
were broken. Checking further, I could retrieve the Windows PATH with getenv("PATH")
but not several other variables set by my application installation, or even some others (e.g. PSModulePath
).
Using phpinfo()
, I cannot see these Windows env variables as they used be when I ran the PHP as apache module (mod_php
).
I have laid out other details of my httpd.conf
over at Serverfault (http://serverfault.com/questions/675736/apache-2-4-with-mod-fcgid-getenv-not-working-in-php) , where the detailed version of this question is yet unanswered.
Basically, is there a fundamental reason why php getenv()
, when running on mod_fcgid
, should retrieve only certain variables (maybe those originally installed with the operating system, I'm guessing), but ignore those subsequently set by other applications?
I've foraged google for close to 48 hours now, and found nothing tangible. Could anyone please be kind enough to assist with insights.
Thank you.
Source: (StackOverflow)
(lastest fcgid module)
OS: Windows Xp prof SP3
I place file mod_fcgid.so in directory (modules)
// Httpd.conf
LoadModule fcgid_module modules/mod_fcgid.so
But. When i try run http (from cmd - for test purpose)
I get error:
httpd: Syntax error on line 515 of C:/Core/Apache24/conf/httpd.conf: Cannot load
C:/Core/Apache24/modules/mod_fcgid.so into server: Nie mo\xbfna odnale\x9f\xe6
okre\x9clonego modu\xb3u.
Path is correct. So what is bad?
Source: (StackOverflow)
I hope that this is the right place to ask this question, so:
We are running a Debian (virtualized) server with Apache running php as fcgi. Today the administrator told me that the processes are consuming the RAM on the system. He asked me to look around my code.
Well I think that virtually I have no control over the php processes since Apache spawns them, so this seems more like a server configuration problem. It seems that every request spawns a new php process (this is ok). After my script terminates the php process goes to sleep.
This is what top looks like. I sorted by memory and these are the php processes (they run on the user edem):
top - 14:49:35 up 41 days, 2:09, 2 users, load average: 0.16, 0.13, 0.06
Tasks: 228 total, 1 running, 227 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.7%us, 0.3%sy, 0.0%ni, 98.7%id, 0.0%wa, 0.0%hi, 0.3%si, 0.0%st
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
12358 edem 20 0 67380 6464 2976 S 0.3 0.2 0:00.06 php
12250 edem 20 0 66960 9776 6584 S 0.0 0.3 0:00.11 php
12253 edem 20 0 67480 7812 3832 S 0.0 0.3 0:00.19 php
12254 edem 20 0 67464 7108 3316 S 0.0 0.2 0:00.07 php
12255 edem 20 0 67404 7340 3604 S 0.0 0.2 0:00.14 php
12256 edem 20 0 67464 7128 3336 S 0.0 0.2 0:00.07 php
12257 edem 20 0 67380 6484 3000 S 0.0 0.2 0:00.04 php
12258 edem 20 0 67464 7092 3312 S 0.0 0.2 0:00.05 php
12259 edem 20 0 67464 7184 3392 S 0.0 0.2 0:00.07 php
12260 edem 20 0 67464 7088 3296 S 0.0 0.2 0:00.06 php
12263 edem 20 0 66960 9780 6584 S 0.0 0.3 0:00.11 php
12265 edem 20 0 67464 7084 3280 S 0.0 0.2 0:00.09 php
12266 edem 20 0 67436 7376 3600 S 0.0 0.2 0:00.14 php
12267 edem 20 0 67464 7144 3340 S 0.0 0.2 0:00.06 php
12268 edem 20 0 67380 6508 3016 S 0.0 0.2 0:00.05 php
12269 edem 20 0 67540 7672 3820 S 0.0 0.2 0:00.22 php
12270 edem 20 0 67496 6488 3040 S 0.0 0.2 0:00.05 php
12271 edem 20 0 67436 7372 3596 S 0.0 0.2 0:00.15 php
12272 edem 20 0 67464 7108 3304 S 0.0 0.2 0:00.07 php
12277 edem 20 0 66960 9776 6584 S 0.0 0.3 0:00.11 php
12279 edem 20 0 67436 7368 3596 S 0.0 0.2 0:00.15 php
12280 edem 20 0 67464 7096 3296 S 0.0 0.2 0:00.07 php
12281 edem 20 0 67464 7748 3808 S 0.0 0.2 0:00.18 php
12282 edem 20 0 67496 7388 3600 S 0.0 0.2 0:00.14 php
12283 edem 20 0 67380 6464 2976 S 0.0 0.2 0:00.04 php
12284 edem 20 0 67380 6464 2976 S 0.0 0.2 0:00.05 php
12285 edem 20 0 67464 7168 3368 S 0.0 0.2 0:00.07 php
12286 edem 20 0 67464 7104 3304 S 0.0 0.2 0:00.06 php
12287 edem 20 0 66960 9780 6584 S 0.0 0.3 0:00.11 php
12289 edem 20 0 67464 7140 3336 S 0.0 0.2 0:00.07 php
Do you have any ide how to kill those sleeping (idling) php processes? Is there something I'm doing wrong?
Source: (StackOverflow)
I would like to upload large files up to 50GB.
I edited my php.ini
max_execution_time = 18000
max_input_time = 18000
post_max_size = 50G
upload_max_filesize = 50G
I increased mod_fcgid values in my vhost
IdleTimeout 18000
ProcessLifeTime 18000
FcgidMaxRequestLen 64424509440
FcgidIOTimeout 18000
I can upload files around 2-3GB maximum, but for more there are two cases:
- No error in apache logs for files around 10GB
- An error for files around 5GB : (70008)Partial results are valid but processing is incomplete: mod_fcgid: can't get data from http client
The site (if it can help you) : http://filetransfer.fr
Thank you in advance to any one who will help me !
Debian 7, apache 2.2.22, PHP 5.4.45
Source: (StackOverflow)
I have a problem on multiple servers than use Apache module mod_fcgid to serve a cgi script that processes the request (ticket validation and similar processing) then serves files on the server based on the result of the processing.
I keep getting the following errors repeatedly in the logs:
[Mon Jan 30 23:11:41 2012] [warn] [client 95.35.160.193] mod_fcgid: error reading data, FastCGI server closed connection
[Mon Jan 30 23:11:41 2012] [warn] [client 95.35.160.193] (32)Broken pipe: mod_fcgid: ap_pass_brigade failed in handle_request_ipc function
[Mon Jan 30 23:13:34 2012] [warn] [client 37.8.52.128] mod_fcgid: can't apply process slot for /var/www/cgi-bin/assetx.fcgi
These problems cause the server to be slow and other times result in service temporarily unavailable error.
The servers have large traffic on them, I have currently configured the following fcgi directives as below:
FcgidMaxRequestsPerProcess 0
FcgidMaxProcesses 300
FcgidMinProcessesPerClass 0
FcgidIdleTimeout 240
FcgidIOTimeout 240
FcgidBusyTimeout 300
the average load on the servers is normal, the number of processes is on average 250 processes.
I have done research for days about this issue, some say it is a permission problem, I've followed their suggestion, didn't help. I tried to tune the parameters above, these are the final values I tried, but they didn't work as well. I am also trying out nginx to be used instead of apache but I cannot find a suitable way to run the cgi script with this high load on the server using nginx.
What can I do to fix this problem?
Any help will be much appreciated.
Thanks in advance.
Source: (StackOverflow)