luis_chiang
asked on
Error 500, apache + php + fcgi + php_gd
Hi all
I got a problem, when I tried to run a php script. I have configured apache + php using fcgi
but When I try to run a php code that call some php_gd functions it fails
un Jan 31 12:45:23 2010] [warn] (104)Connection reset by peer: mod_fcgid: read data from fastcgi server error.
[Sun Jan 31 12:45:23 2010] [error] [client 192.168.2.110] Premature end of script headers: image.php
I was searching a lot about configuring, suexec, fcgi, etc etc.. but I dont have any answer.
here is my apache config:
<VirtualHost 200.7.210.196:80>
ServerName amatamoros.targetsoft.com. ec
ServerAlias www.amatamoros.targetsoft.com.ec
ServerAlias webmail.amatamoros.targets oft.com.ec
ServerAlias admin.amatamoros.targetsof t.com.ec
DocumentRoot /home/amatamoros/public_ht ml
ErrorLog /var/log/virtualmin/amatam oros.targe tsoft.com. ec_error_l og
CustomLog /var/log/virtualmin/amatam oros.targe tsoft.com. ec_access_ log combined
ScriptAlias /cgi-bin/ /home/amatamoros/cgi-bin/
ScriptAlias /awstats /home/amatamoros/cgi-bin
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /home/amatamoros/public_ht ml>
Options -Indexes IncludesNOEXEC FollowSymLinks ExecCGI
allow from all
AllowOverride All
AddHandler fcgid-script .php
AddHandler fcgid-script .php5
FCGIWrapper /home/amatamoros/fcgi-bin/ php5.fcgi .php
FCGIWrapper /home/amatamoros/fcgi-bin/ php5.fcgi .php5
</Directory>
<Directory /home/amatamoros/cgi-bin>
allow from all
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.amatamoros.target soft.com.e c
RewriteRule ^(.*) https://amatamoros.targetsoft.com.ec:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.amatamoros.targetso ft.com.ec
RewriteRule ^(.*) https://amatamoros.targetsoft.com.ec:10000/ [R]
RemoveHandler .php
RemoveHandler .php5
Alias /dav /home/amatamoros/public_ht ml
Alias /pipermail /var/lib/mailman/archives/ public
<Location /dav>
DAV On
AuthType Basic
AuthName amatamoros.targetsoft.com. ec
AuthUserFile /home/amatamoros/etc/dav.d igest.pass wd
Require valid-user
ForceType text/plain
Satisfy All
RemoveHandler .php
RemoveHandler .php5
</Location>
<Files awstats.pl>
AuthName "amatamoros.targetsoft.com .ec statistics"
AuthType Basic
AuthUserFile /home/amatamoros/.awstats- htpasswd
require valid-user
</Files>
RedirectMatch /cgi-bin/mailman/([^/\.]*) (.cgi)?(.* ) https://amatamoros.targetsoft.com.ec:10000/virtualmin-mailman/unauthenticated/$1.cgi$3
RedirectMatch /mailman/([^/\.]*)(.cgi)?( .*) https://amatamoros.targetsoft.com.ec:10000/virtualmin-mailman/unauthenticated/$1.cgi$3
SuexecUserGroup "#505" "#506"
</VirtualHost>
and my fcgi configuration:
#!/bin/bash
PHPRC=$PWD/../etc/php5
export PHPRC
umask 022
SCRIPT_FILENAME=$PATH_TRAN SLATED
export SCRIPT_FILENAME
exec /usr/bin/php-cgi
Im using centos.
please help me!!
I got a problem, when I tried to run a php script. I have configured apache + php using fcgi
but When I try to run a php code that call some php_gd functions it fails
un Jan 31 12:45:23 2010] [warn] (104)Connection reset by peer: mod_fcgid: read data from fastcgi server error.
[Sun Jan 31 12:45:23 2010] [error] [client 192.168.2.110] Premature end of script headers: image.php
I was searching a lot about configuring, suexec, fcgi, etc etc.. but I dont have any answer.
here is my apache config:
<VirtualHost 200.7.210.196:80>
ServerName amatamoros.targetsoft.com.
ServerAlias www.amatamoros.targetsoft.com.ec
ServerAlias webmail.amatamoros.targets
ServerAlias admin.amatamoros.targetsof
DocumentRoot /home/amatamoros/public_ht
ErrorLog /var/log/virtualmin/amatam
CustomLog /var/log/virtualmin/amatam
ScriptAlias /cgi-bin/ /home/amatamoros/cgi-bin/
ScriptAlias /awstats /home/amatamoros/cgi-bin
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /home/amatamoros/public_ht
Options -Indexes IncludesNOEXEC FollowSymLinks ExecCGI
allow from all
AllowOverride All
AddHandler fcgid-script .php
AddHandler fcgid-script .php5
FCGIWrapper /home/amatamoros/fcgi-bin/
FCGIWrapper /home/amatamoros/fcgi-bin/
</Directory>
<Directory /home/amatamoros/cgi-bin>
allow from all
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.amatamoros.target
RewriteRule ^(.*) https://amatamoros.targetsoft.com.ec:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.amatamoros.targetso
RewriteRule ^(.*) https://amatamoros.targetsoft.com.ec:10000/ [R]
RemoveHandler .php
RemoveHandler .php5
Alias /dav /home/amatamoros/public_ht
Alias /pipermail /var/lib/mailman/archives/
<Location /dav>
DAV On
AuthType Basic
AuthName amatamoros.targetsoft.com.
AuthUserFile /home/amatamoros/etc/dav.d
Require valid-user
ForceType text/plain
Satisfy All
RemoveHandler .php
RemoveHandler .php5
</Location>
<Files awstats.pl>
AuthName "amatamoros.targetsoft.com
AuthType Basic
AuthUserFile /home/amatamoros/.awstats-
require valid-user
</Files>
RedirectMatch /cgi-bin/mailman/([^/\.]*)
RedirectMatch /mailman/([^/\.]*)(.cgi)?(
SuexecUserGroup "#505" "#506"
</VirtualHost>
and my fcgi configuration:
#!/bin/bash
PHPRC=$PWD/../etc/php5
export PHPRC
umask 022
SCRIPT_FILENAME=$PATH_TRAN
export SCRIPT_FILENAME
exec /usr/bin/php-cgi
Im using centos.
please help me!!
ASKER
Thanks for your reply,
I'm guessing that the problem is like configuration, because sometimes(1 of 300 tries) runs and another not.
The same code is running in another server fine, but in my server have problems.
here the output of <pre><?php print_r(gd_info()); ?></pre>
Array ( [GD Version] => bundled (2.0.28 compatible) [FreeType Support] => 1 [FreeType Linkage] => with freetype [T1Lib Support] => [GIF Read Support] => 1 [GIF Create Support] => 1 [JPG Support] => 1 [PNG Support] => 1 [WBMP Support] => 1 [XPM Support] => [XBM Support] => 1 [JIS-mapped Japanese Font Support] => )
the result of phpinfo();
Configure Command
'./configure' '--build=i686-redhat-linux -gnu' '--host=i686-redhat-linux- gnu' '--target=i386-redhat-linu x-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include ' '--libdir=/usr/lib' '--libexecdir=/usr/libexec ' '--localstatedir=/var' '--sharedstatedir=/usr/com ' '--mandir=/usr/share/man' '--infodir=/usr/share/info ' '--cache-file=../config.ca che' '--with-libdir=lib' '--with-config-file-path=/ etc' '--with-config-file-scan-d ir=/etc/ph p.d' '--disable-debug' '--with-pic' '--disable-rpath' '--without-pear' '--with-bz2' '--with-curl' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-png' '--with-pspell' '--with-expat-dir=/usr' '--with-pcre-regex=/usr' '--with-zlib' '--with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-track-vars' '--enable-trans-sid' '--enable-yp' '--enable-wddx' '--with-kerberos' '--enable-ucd-snmp-hack' '--with-unixODBC=shared,/u sr' '--enable-memory-limit' '--enable-shmop' '--enable-calendar' '--enable-dbx' '--enable-dio' '--with-mime-magic=/usr/sh are/file/m agic.mime' '--without-sqlite' '--with-libxml-dir=/usr' '--with-xml' '--with-system-tzdata' '--enable-force-cgi-redire ct' '--enable-pcntl' '--with-imap=shared' '--with-imap-ssl' '--enable-mbstring=shared' '--enable-mbstr-enc-trans' '--enable-mbregex' '--with-ncurses=shared' '--with-gd=shared' '--enable-bcmath=shared' '--enable-dba=shared' '--with-db4=/usr' '--with-xmlrpc=shared' '--with-ldap=shared' '--with-ldap-sasl' '--with-mysql=shared,/usr' '--with-mysqli=shared,/usr /lib/mysql /mysql_con fig' '--enable-dom=shared' '--with-dom-xslt=/usr' '--with-dom-exslt=/usr' '--with-pgsql=shared' '--with-snmp=shared,/usr' '--enable-soap=shared' '--with-xsl=shared,/usr' '--enable-xmlreader=shared ' '--enable-xmlwriter=shared ' '--enable-fastcgi' '--enable-pdo=shared' '--with-pdo-odbc=shared,un ixODBC,/us r' '--with-pdo-mysql=shared,/ usr/lib/my sql/mysql_ config' '--with-pdo-pgsql=shared,/ usr' '--with-pdo-sqlite=shared, /usr' '--enable-dbase=shared'
Configuration File (php.ini) Path /home/amatamoros/etc/php5/ php.ini
Scan this dir for additional .ini files
/etc/php.d
additional .ini files parsed /etc/php.d/Fileinfo.ini, /etc/php.d/bcmath.ini, /etc/php.d/dba.ini, /etc/php.d/dbase.ini, /etc/php.d/dom.ini, /etc/php.d/gd.ini, /etc/php.d/imap.ini, /etc/php.d/ldap.ini, /etc/php.d/mbstring.ini, /etc/php.d/mcrypt.ini, /etc/php.d/memcache.ini, /etc/php.d/mhash.ini, /etc/php.d/mssql.ini, /etc/php.d/mysql.ini, /etc/php.d/mysqli.ini, /etc/php.d/ncurses.ini, /etc/php.d/odbc.ini, /etc/php.d/pdo.ini, /etc/php.d/pdo_mysql.ini, /etc/php.d/pdo_odbc.ini, /etc/php.d/pdo_pgsql.ini, /etc/php.d/pdo_sqlite.ini, /etc/php.d/pgsql.ini, /etc/php.d/readline.ini, /etc/php.d/snmp.ini, /etc/php.d/soap.ini, /etc/php.d/tidy.ini, /etc/php.d/xmlreader.ini, /etc/php.d/xmlrpc.ini, /etc/php.d/xmlwriter.ini, /etc/php.d/xsl.ini
GD Support enabled
GD Version bundled (2.0.28 compatible)
my code is attached.
and my php.ini too
please give me a recommendation
audioexprt.zip
php.ini
I'm guessing that the problem is like configuration, because sometimes(1 of 300 tries) runs and another not.
The same code is running in another server fine, but in my server have problems.
here the output of <pre><?php print_r(gd_info()); ?></pre>
Array ( [GD Version] => bundled (2.0.28 compatible) [FreeType Support] => 1 [FreeType Linkage] => with freetype [T1Lib Support] => [GIF Read Support] => 1 [GIF Create Support] => 1 [JPG Support] => 1 [PNG Support] => 1 [WBMP Support] => 1 [XPM Support] => [XBM Support] => 1 [JIS-mapped Japanese Font Support] => )
the result of phpinfo();
Configure Command
'./configure' '--build=i686-redhat-linux
Configuration File (php.ini) Path /home/amatamoros/etc/php5/
Scan this dir for additional .ini files
/etc/php.d
additional .ini files parsed /etc/php.d/Fileinfo.ini, /etc/php.d/bcmath.ini, /etc/php.d/dba.ini, /etc/php.d/dbase.ini, /etc/php.d/dom.ini, /etc/php.d/gd.ini, /etc/php.d/imap.ini, /etc/php.d/ldap.ini, /etc/php.d/mbstring.ini, /etc/php.d/mcrypt.ini, /etc/php.d/memcache.ini, /etc/php.d/mhash.ini, /etc/php.d/mssql.ini, /etc/php.d/mysql.ini, /etc/php.d/mysqli.ini, /etc/php.d/ncurses.ini, /etc/php.d/odbc.ini, /etc/php.d/pdo.ini, /etc/php.d/pdo_mysql.ini, /etc/php.d/pdo_odbc.ini, /etc/php.d/pdo_pgsql.ini, /etc/php.d/pdo_sqlite.ini,
GD Support enabled
GD Version bundled (2.0.28 compatible)
my code is attached.
and my php.ini too
please give me a recommendation
audioexprt.zip
php.ini
OK.
1 - The header you are sending is image/jpeg, but you are generating a PNG file (imagepng()).
Try changing...
header("Content-type: image/jpeg");
to
header("Content-type: image/png");
2 - You are not sending any cache avoidance headers, so maybe you are getting a cached file each time.
Try adding ...
header("Cache-Control: no-cache, must-revalidate, , post-check=0, pre-check=0");
header("Expires: 0");
just after the content-type header.
1 - The header you are sending is image/jpeg, but you are generating a PNG file (imagepng()).
Try changing...
header("Content-type: image/jpeg");
to
header("Content-type: image/png");
2 - You are not sending any cache avoidance headers, so maybe you are getting a cached file each time.
Try adding ...
header("Cache-Control: no-cache, must-revalidate, , post-check=0, pre-check=0");
header("Expires: 0");
just after the content-type header.
ASKER
Hi,
I try your recommendation, but It doesn't works... I was trying before with the png or jpeg content-tye and doesn't works too now, something rare is that the code runs well on another server.
sometimes I comment some lines like :
imagefill($brush,0,0,$azul );
imagesetbrush($im,$brush);
and just open the file and flush it out to the stream, It's works fine. I don't know if it is any memory limit problem.
thanks
I try your recommendation, but It doesn't works... I was trying before with the png or jpeg content-tye and doesn't works too now, something rare is that the code runs well on another server.
sometimes I comment some lines like :
imagefill($brush,0,0,$azul
imagesetbrush($im,$brush);
and just open the file and flush it out to the stream, It's works fine. I don't know if it is any memory limit problem.
thanks
When it doesn't work, do you get an error message? Can you see your errors log? Are you logging errors?
There must be something...
<?php
error_reporting(-1); // Turn on ALL errors/warnings/notices.
ini_set('display_errors', 0); // Don't show them to the client.
ini_set('log_errors', 1); // Log errors.
ini_set('error_log', './errors.log'); // Log errors to this file.
set_time_limit(0); // Allow the program to run forever.
There must be something...
<?php
error_reporting(-1); // Turn on ALL errors/warnings/notices.
ini_set('display_errors', 0); // Don't show them to the client.
ini_set('log_errors', 1); // Log errors.
ini_set('error_log', './errors.log'); // Log errors to this file.
set_time_limit(0); // Allow the program to run forever.
ASKER
Yes, I look at my logs files, and only can see these message,
[Tue Feb 02 13:56:21 2010] [warn] (104)Connection reset by peer: mod_fcgid: read data from fastcgi server error.
[Tue Feb 02 13:56:21 2010] [error] [client 190.154.5.187] Premature end of script headers: americana.php
and I added your lines, but nothing, still sending the same Error 500, and the same log. and the file errors.log is empty
[Tue Feb 02 13:56:21 2010] [warn] (104)Connection reset by peer: mod_fcgid: read data from fastcgi server error.
[Tue Feb 02 13:56:21 2010] [error] [client 190.154.5.187] Premature end of script headers: americana.php
and I added your lines, but nothing, still sending the same Error 500, and the same log. and the file errors.log is empty
ASKER
Hi,
I guess I found more information about the error, I change FCGI to CGI.. and here is the error log... I'm running my server virtualized by hyper-v... but here is the output of the log, no integration tools installed
and still getting the error 500, but now its send me a file with extension .php and its contains the html of the error 500.
[Tue Feb 02 14:44:48 2010] [error] [client 190.154.5.187] *** glibc detected *** /usr/bin/php-cgi: malloc(): memory corruption: 0x094b7828 ***
do you have any recommendation?
error.txt
I guess I found more information about the error, I change FCGI to CGI.. and here is the error log... I'm running my server virtualized by hyper-v... but here is the output of the log, no integration tools installed
and still getting the error 500, but now its send me a file with extension .php and its contains the html of the error 500.
[Tue Feb 02 14:44:48 2010] [error] [client 190.154.5.187] *** glibc detected *** /usr/bin/php-cgi: malloc(): memory corruption: 0x094b7828 ***
do you have any recommendation?
error.txt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
After I update to php 5.2 everything is well
1 - Can you create info.php containing
<?php phpinfo(); ?>
and show the results.
Specifically, I'm looking for the "Configure Command", "Configuration File (php.ini) Path", "Loaded Configuration File", "Scan this dir for additional .ini files" and "additional .ini files parsed"
as well as ...
GD Support enabled
GD Version bundled (2.0.34 compatible)
2 - Assuming that is all OK. Create a prove_gd.php file with ...
<pre><?php print_r(gd_info()); ?></pre>
That should produce something similar to the output as part of phpinfo().
3 - Let's see the code you are using?
4 - In the code, remove any headers() you use to send the image to the client. Can you run the URL to the php script directly? What errors do you get?