PDA

View Full Version : Magento Commerce with Fast-CGI and suExec


doughold
22nd April 2009, 21:52
I have been able to sucessfully install the platform and can access the homepage and user front end just fine. However, when I try to log in to the back end I am getting a 500 internal error message. This is from the users log file:

[Wed Apr 22 14:30:14 2009] [warn] mod_fcgid: read data timeout in 40 seconds
[Wed Apr 22 14:30:14 2009] [error] [client <MY IP>] Premature end of script headers: index.php

This is from the Apache log file:
[Wed Apr 22 14:28:54 2009] [notice] mod_fcgid: call /var/www/tt.westechsolutions.com/web/index.php with wrapper /var/www/php-fcgi-scripts/web35/.php-fcgi-starter
[Wed Apr 22 14:30:14 2009] [notice] mod_fcgid: process 1556 going graceful shutdown, sending SIGTERM
[Wed Apr 22 14:30:20 2009] [notice] mod_fcgid: process /var/www/tt.westechsolutions.com/web/index.php(1571) exit(communication error), terminated by calling exit(), return code: 0

This is my .htaccess file:
############################################
## uncomment these lines for CGI mode
## make sure to specify the correct cgi php binary file name
## it might be /cgi-bin/php-cgi

# Action php5-cgi /cgi-bin/php5-cgi
# AddHandler php5-cgi .php

############################################
## GoDaddy specific options

# Options -MultiViews

## you might also need to add this line to php.ini
## cgi.fix_pathinfo = 1
## if it still doesn't work, rename php.ini to php5.ini

############################################
## this line is specific for 1and1 hosting

#AddType x-mapp-php5 .php
#AddHandler x-mapp-php5 .php

############################################
## default index file

DirectoryIndex index.php

<IfModule mod_php5.c>

############################################
## adjust memory limit

# php_value memory_limit 64M
php_value memory_limit 128M
php_value max_execution_time 18000

############################################
## disable magic quotes for php request vars

php_flag magic_quotes_gpc off

############################################
## disable automatic session start
## before autoload was initialized

php_flag session.auto_start off

############################################
## enable resulting html compression

#php_flag zlib.output_compression on

###########################################
# disable user agent verification to not break multiple image upload

php_flag suhosin.session.cryptua off

###########################################
# turn off compatibility with PHP4 when dealing with objects

php_flag zend.ze1_compatibility_mode Off

</IfModule>

<IfModule mod_security.c>
###########################################
# disable POST processing to not break multiple image upload

SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>

<IfModule mod_deflate.c>

############################################
## enable apache served files compression
## http://developer.yahoo.com/performance/rules.html#gzip

# Insert filter on all content
###SetOutputFilter DEFLATE
# Insert filter on selected content types only
#AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript

# Netscape 4.x has some problems...
#BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
#BrowserMatch ^Mozilla/4\.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
#BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# Don't compress images
#SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary

# Make sure proxies don't deliver the wrong content
#Header append Vary User-Agent env=!dont-vary

</IfModule>

<IfModule mod_ssl.c>

############################################
## make HTTPS env vars available for CGI mode

SSLOptions StdEnvVars

</IfModule>

<IfModule mod_rewrite.c>

############################################
## enable rewrites

Options +FollowSymLinks
RewriteEngine on

############################################
## you can put here your magento root folder
## path relative to web root

#RewriteBase /magento/

############################################
## workaround for HTTP authorization
## in CGI environment

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

############################################
## always send 404 on missing files in these folders

RewriteCond %{REQUEST_URI} !^/(media|skin|js)/

############################################
## never rewrite for existing files, directories and links

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l

############################################
## rewrite everything else to index.php

RewriteRule .* index.php [L]

</IfModule>


############################################
## Prevent character encoding issues from server overrides
## If you still have problems, use the second line instead

AddDefaultCharset Off
#AddDefaultCharset UTF-8

<IfModule mod_expires.c>

############################################
## Add default Expires header
## http://developer.yahoo.com/performance/rules.html#expires

ExpiresDefault "access plus 1 year"

</IfModule>

############################################
## By default allow all access

Order allow,deny
Allow from all

############################################
## If running in cluster environment, uncomment this
## http://developer.yahoo.com/performance/rules.html#etags

#FileETag none


It seems very strange to me that the main site works and the admin section doesn't. Although I feel like it might have something to do with the rewrites that the .htaccess file does. I am not very familiar with FCGI/SuEXEC yet so bear with me if I missed something obvious.

till
23rd April 2009, 11:47
Are there any additional errors in the error.log file which is located in the log directory of this specific website?

doughold
23rd April 2009, 17:09
Unfortunately there is nothing else in the log that shows up when the script fails. I've read in a few places that SuExec doesn't work with php directives in the .htaccess file, so I had commented those out but it didn't help.

falko
24th April 2009, 16:26
What happens when you completely remove the .htaccess file?

What's in /var/www/php-fcgi-scripts/web35/.php-fcgi-starter?

doughold
24th April 2009, 17:07
I get a 404 error when I got to /admin b/c it was using url rewrites and that directory doesn't exist.

My .php-fcgi-starter is:
#!/bin/sh
PHPRC="/etc/php5/cgi/"
export PHPRC
PHP_DOCUMENT_ROOT="/var/clients/client10/web35"
export PHP_DOCUMENT_ROOT
PHP_FCGI_CHILDREN=8
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_MAX_REQUESTS
exec /usr/bin/php-cgi $1

falko
25th April 2009, 12:50
What's the output of ls -la /var/clients/client10/web35/?
What's the output of ls -l /usr/bin/php-cgi?

Have you tried to restart Apache?

doughold
26th April 2009, 01:26
drwxr-xr-x 6 root root 4096 2009-04-22 14:20 .
drwxr-xr-x 3 root root 4096 2009-04-15 20:15 ..
drwxr-xr-x 2 web35 client10 4096 2009-04-22 15:19 cgi-bin
lrwxrwxrwx 1 web35 client10 48 2009-04-15 20:15 log -> /var/log/ispconfig/httpd/tt.westechsolutions.com
-rw-r--r-- 1 web35 client10 751 2009-04-22 18:19 php.ini
drwxr-xr-x 2 web35 client10 4096 2009-04-15 20:15 ssl
drwxrwxrwx 2 web35 client10 4096 2009-04-15 20:15 tmp
drwxr-xr-x 14 web35 client10 4096 2009-04-24 10:06 web


root@ispconfig3:~# ls -la /usr/bin/php-cgi
lrwxrwxrwx 1 root root 25 2008-09-21 09:08 /usr/bin/php-cgi -> /etc/alternatives/php-cgi

falko
26th April 2009, 14:32
Have you tried to restart Apache?

If that doesn't help, try this:
chown web35:client10 /var/clients/client10/web35

doughold
28th April 2009, 01:45
I have restarted apache (and even the whole server) and it didn't help. Additionally, I ran the code you suggested and that didn't help either. I also ran:


root@ispconfig3:~# chown web35:client10 /var/clients/client10/web35
root@ispconfig3:~# chown -R web35:client10 /var/clients/client10/web35/web
root@ispconfig3:~# chmod -R 755 /var/clients/client10/web35/web


To make sure all files were rwx by the web35 user. This didn't help either.

falko
28th April 2009, 17:47
Hm, I have no idea what's wrong... :(

doughold
28th April 2009, 22:05
Yeah me either. It's kind of a bummer, but luckily I got the site working by installing a previous release. There must be a bug in one of the .htaccess files or php scripts that was causing the 500 error. Hopefully this will be resolved in future releases, though I didn't see anything about it in the community forums. Thanks for all of your help I really appreciate it. Keep it up!

doughold
22nd May 2009, 16:54
The problem is basically that in 1.3.1+ there are outbound calls made to get some files for widgets in the backend. The process that got me to this conclusion was first setting these apache directives (under options tab in the website):

<IfModule mod_fcgid.c>
IPCConnectTimeout 300
IPCCommTimeout 360
</IfModule>

I was then finally able to move around the backend without any internal 500 error messages popping up, though it took 3-5min to get from page to page. I kept investigating further and came across the following thread:

http://www.magentocommerce.com/boards/viewthread/39726/

Basically, you have to disable the widget requests made by the server by doing the following:


Solution - disable widgets - quick and dirty way!
Edit function canShow:

/app/code/core/Mage/Adminhtml/Block/Notification/Window.php

public function canShow()
{
return false;
}


Hope this helps!

safoo
22nd May 2009, 17:07
Thanks for updating the thread. I get the 500 internal error on some page loads, even on front end. After I get the 500 error, the next page load works, so perhaps its more a memory issue. The entry in the log is what was cause for concern.

I'm on a test server right now, so we'll see how everything goes when working on production.

I'll bookmark this page in case it happens consistently on the backend.

doughold
22nd May 2009, 17:11
Yeah that seems like a different issue than what I ran into.

If that is the case, the apache directives might help you out by increasing the timout length for the scripts to run.