Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
 Post subject: Magento on Nginx Issue
PostPosted: Thu Apr 26, 2012 3:09 pm 
Offline
Senior Newbie

Joined: Wed Nov 23, 2011 11:01 am
Posts: 16
ICQ: 35213257
Website: http://freshma.de/
Location: Saint Louis, MO
This may be more of an Nginx issue but I've not found any solid information on the topic. I grabbed the latest from Magento via curl, moved the extracted files into the directory where I want Magento to live (currently a sub-domain).

Small back story, I initially moved from Dreamhost last year to Linode for more flexibility and ran this StackScript to get the ball rolling "Better WordPress with WP SuperCache & Nginx" StackScript at revision 14407 - and I really dig it as most of my sites are custom rolled PHP or Wordpress.

Now, the issue, I'm trying to stand up Magento for a small shop (that will eventually grow to a larger catalog) and getting 502 Bad Gateway. I've googled LEMP+Magento, Nginx+Magento and various other flavors but none of the responses seem to get at the issue properly.

My first attempt was to follow this guide: http://www.magentocommerce.com/wiki/1_- ... or_magento < got me to the 502

Other attempts led me around this post: http://www.magentocommerce.com/boards/viewthread/7931/ < not really anything helpful there

So I thought I'd shoot this over to the Linode side as the Magento folks (from dealing with in the past) have always seemed snarky and generally not into being helpful.

My current config: (domain sanitized for safety, not sure if this config would really be dangerous however)

Code:
server {
    listen 80;
    rewrite / $scheme://$host$request_uri permanent; ## Forcibly remove a www
}

server {
    listen 80 default;
    server_name my.domain.com;
    root /srv/www/my.domain.com/public_html;
 
    location / {
        index index.html index.php; ## Allow a static html file to be shown first
        try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
        expires 30d; ## Assume all files are cachable
    }

    ## These locations would be hidden by .htaccess normally
    location /app/                { deny all; }
    location /includes/           { deny all; }
    location /lib/                { deny all; }
    location /lib/minify/         { allow all; }  ## Deny is applied after rewrites so must specifically allow minify
    location /media/downloadable/ { deny all; }
    location /pkginfo/            { deny all; }
    location /report/config.xml   { deny all; }
    location /var/                { deny all; }

    location /var/export/ { ## Allow admins only to view export folder
        auth_basic           "Restricted"; ## Message shown in login window
        auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword
        autoindex            on;
    }

    location  /. { ## Disable .htaccess and other hidden files
        return 404;
    }

    location @handler { ## Magento uses a common front handler
        rewrite / /index.php;
    }

    location ~ \.php/ { ## Forward paths like /js/index.php/x.js to relevant handler
        rewrite ^(.*\.php)/ $1 last;
    }

    location ~ \.php$ { ## Execute PHP scripts
        expires        off; ## Do not cache dynamic content
        fastcgi_pass   127.0.0.1:9000;
        #fastcgi_param  HTTPS $fastcgi_https; ## Removed for now as PayPal will handle secure transactions, and it threw an error
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params; ## See /etc/nginx/fastcgi_params
    }
}


There you have it, any Nginx wizards see what I'm doing wrong, or have a better resource I can comb through perhaps?

Thanks all in advance!

_________________
Newbie to Linode, excited to be here!


Top
   
 Post subject:
PostPosted: Sat Apr 28, 2012 1:01 am 
Offline
Senior Newbie

Joined: Fri Jan 28, 2011 10:21 am
Posts: 17
Location: Kiev, Ukraine
It looks like that you dont have any backend at 127.0.0.1:9000. What backend do you use for php: apache or php-fpm?


Top
   
 Post subject:
PostPosted: Sat Apr 28, 2012 1:27 am 
Offline
Senior Newbie

Joined: Wed Nov 23, 2011 11:01 am
Posts: 16
ICQ: 35213257
Website: http://freshma.de/
Location: Saint Louis, MO
Net-burst wrote:
It looks like that you dont have any backend at 127.0.0.1:9000. What backend do you use for php: apache or php-fpm?

Here is where my ineptitude will shine, I'd go with php-fpm if those are my only two choices, I never installed apache on the box. But I do have /etc/php5/fpm/ if that helps.

Sorry for my lack of knowledge in this, I'm not by nature a sysadmin I just muddle through as best I can.

If you have a little insight to what you'd be my hero!

_________________
Newbie to Linode, excited to be here!


Top
   
 Post subject:
PostPosted: Thu May 03, 2012 10:02 am 
Offline
Senior Newbie

Joined: Wed Nov 23, 2011 11:01 am
Posts: 16
ICQ: 35213257
Website: http://freshma.de/
Location: Saint Louis, MO
Anyone have an insight to this? I'm more than happy to try setting up a backend as mentioned before however I'm not sure where to start with that.

Thanks for any help!

_________________
Newbie to Linode, excited to be here!


Top
   
 Post subject:
PostPosted: Thu May 03, 2012 10:19 am 
Offline
Senior Member

Joined: Sun Mar 07, 2010 7:47 pm
Posts: 1970
Website: http://www.rwky.net
Location: Earth
What distribution are you running?

_________________
Paid support
How to ask for help
1. Give details of your problem
2. Post any errors
3. Post relevant logs.
4. Don't hide details i.e. your domain, it just makes things harder
5. Be polite or you'll be eaten by a grue


Top
   
 Post subject:
PostPosted: Thu May 03, 2012 10:31 am 
Offline
Senior Newbie

Joined: Wed Nov 23, 2011 11:01 am
Posts: 16
ICQ: 35213257
Website: http://freshma.de/
Location: Saint Louis, MO
Ubuntu 10.10, not sure if I'm up to upgrade to the latest just yet.

_________________
Newbie to Linode, excited to be here!


Top
   
 Post subject:
PostPosted: Thu May 03, 2012 10:44 am 
Offline
Senior Member

Joined: Sun Mar 07, 2010 7:47 pm
Posts: 1970
Website: http://www.rwky.net
Location: Earth
To be honest you might as well upgrade and get it out of the way now then all your site disruption is in one go, once upgraded you'll be set for the next five years.

Also what does aptitude show php5-fpm say?

_________________
Paid support
How to ask for help
1. Give details of your problem
2. Post any errors
3. Post relevant logs.
4. Don't hide details i.e. your domain, it just makes things harder
5. Be polite or you'll be eaten by a grue


Top
   
 Post subject:
PostPosted: Thu May 03, 2012 11:50 am 
Offline
Senior Newbie

Joined: Wed Nov 23, 2011 11:01 am
Posts: 16
ICQ: 35213257
Website: http://freshma.de/
Location: Saint Louis, MO
obs wrote:
To be honest you might as well upgrade and get it out of the way now then all your site disruption is in one go, once upgraded you'll be set for the next five years.

Also what does aptitude show php5-fpm say?


The command gives me:

Package: php5-fpm
New: yes
State: installed
Automatically installed: no
Version: 5.3.3-1ubuntu9.6
Priority: optional
Section: universe/php
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Uncompressed Size: 7,811k
Depends: libbz2-1.0, libc6 (>= 2.11), libcomerr2 (>= 1.01), libdb4.8,
libevent-1.4-2 (>= 1.4.13-stable), libgssapi-krb5-2 (>= 1.6.dfsg.2),
libk5crypto3 (>= 1.6.dfsg.2), libkrb5-3 (>= 1.6.dfsg.2), libpcre3 (>=
7.7), libssl0.9.8 (>= 0.9.8m-1), libxml2 (>= 2.7.4), zlib1g (>=
1:1.1.4), mime-support, php5-common (= 5.3.3-1ubuntu9.6), libmagic1,
ucf, tzdata
Suggests: php-pear
Provides: phpapi-20090626+lfs
Description: server-side, HTML-embedded scripting language (FPM-CGI binary)
This package provides the Fast Process Manager interpreter that runs as a
daemon and receives Fast/CGI requests. Note that MOST Apache users probably
want the libapache2-mod-php5 package. The following extensions are built in:
bcmath bz2 calendar Core ctype date
dba dom ereg exif fileinfo filter ftp gettext hash iconv json libxml
mbstring mhash openssl pcre Phar posix Reflection session shmop SimpleXML
soap sockets SPL standard sysvmsg sysvsem sysvshm tokenizer wddx xml
xmlreader xmlwriter zip zlib.

PHP5 is an HTML-embedded scripting language. Much of its syntax is borrowed
from C, Java and Perl with a couple of unique PHP-specific features thrown in.
The goal of the language is to allow web developers to write dynamically
generated pages quickly. This version of PHP5 was built with the Suhosin patch.
Homepage: http://www.php.net/

Also, in regards to the upgrading, I'm just not sure how to do that. I have a enough Linux knowledge to get myself into and out of trouble in most cases but I've never upgraded one via shell. I will try and do some research on the process but I'm just in the unknown camp right now, like would I have to set up all of my sites again and so on?

_________________
Newbie to Linode, excited to be here!


Top
   
 Post subject:
PostPosted: Thu May 03, 2012 6:10 pm 
Offline
Junior Member

Joined: Sun Dec 30, 2007 3:11 pm
Posts: 30
Website: http://www.triptoy.net
Im actually having the SAME exact issue right now. This very moment.

Here is my config. I do have fpm installed (I actually have magento standing on apache on my linode right now, having the issue on a local 12.04 vmware install for testing)

The issue is I get "Error parsing body - doesn't seem to be a chunked message"


Top
   
 Post subject:
PostPosted: Thu May 03, 2012 6:35 pm 
Offline
Senior Member

Joined: Sun Mar 07, 2010 7:47 pm
Posts: 1970
Website: http://www.rwky.net
Location: Earth
Ok to upgrade to 12.04 check out https://help.ubuntu.com/community/PreciseUpgrades I've not done it myself but I've heard that upgrading's been pretty painless from the forums.

What does the output of
Code:
ps aux | grep php
and
Code:
netstat -lpnt
say? Let's see if PHP running and listening.

_________________
Paid support
How to ask for help
1. Give details of your problem
2. Post any errors
3. Post relevant logs.
4. Don't hide details i.e. your domain, it just makes things harder
5. Be polite or you'll be eaten by a grue


Top
   
 Post subject:
PostPosted: Thu May 03, 2012 10:38 pm 
Offline
Senior Newbie

Joined: Wed Nov 23, 2011 11:01 am
Posts: 16
ICQ: 35213257
Website: http://freshma.de/
Location: Saint Louis, MO
obs wrote:
Ok to upgrade to 12.04 check out https://help.ubuntu.com/community/PreciseUpgrades I've not done it myself but I've heard that upgrading's been pretty painless from the forums.

What does the output of
Code:
ps aux | grep php
and
Code:
netstat -lpnt
say? Let's see if PHP running and listening.


Okay: ps aux | grep php
Code:
root      2532  0.0  0.2  39328  1180 ?        Ss    2011  76:22 /usr/sbin/php5-fpm --fpm-config /etc/php5/fpm/main.conf
www-data 31561  0.0  5.9  61744 30212 ?        S    12:46   0:17 /usr/sbin/php5-fpm --fpm-config /etc/php5/fpm/main.conf
www-data 31562  0.0  7.0  67328 35796 ?        S    12:46   0:13 /usr/sbin/php5-fpm --fpm-config /etc/php5/fpm/main.conf
www-data 31563  0.0  6.6  65224 33696 ?        S    12:46   0:12 /usr/sbin/php5-fpm --fpm-config /etc/php5/fpm/main.conf
www-data 31564  0.0  6.4  64140 32612 ?        S    12:47   0:14 /usr/sbin/php5-fpm --fpm-config /etc/php5/fpm/main.conf
root     31917  0.0  0.1   4008   752 pts/0    S+   21:35   0:00 grep php


And netstat -lpnt
Code:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      2149/mysqld     
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      24017/nginx     
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      2068/sshd       
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      2433/exim4     
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      24017/nginx     
tcp6       0      0 :::22                   :::*                    LISTEN      2068/sshd       
tcp6       0      0 ::1:25                  :::*                    LISTEN      2433/exim4 


Hopefully that helps narrow down the issue, stabbing at it the 0.0.0.0:80 for Nginx seems a tad off but I have no issues with any other sites or software so I'm just not sure. Again, n00b with some of this stuff.

_________________
Newbie to Linode, excited to be here!


Top
   
 Post subject:
PostPosted: Fri May 04, 2012 5:42 am 
Offline
Senior Newbie

Joined: Fri Jan 28, 2011 10:21 am
Posts: 17
Location: Kiev, Ukraine
You have php-fpm running, but it listens on a socket, and nginx tries to connect to it through loopback connection. I don know where php-fpm stores its socket file in ubuntu, but it's probably in "/var/run/php-fpm.sock". You can look inside /etc/php5/fpm/main.conf and look for line that starts with "listen" to clarify location of your socket file and than change appropriate line in you nginx config and restart nginx.


Top
   
 Post subject:
PostPosted: Fri May 04, 2012 9:22 am 
Offline
Senior Member

Joined: Sun Mar 07, 2010 7:47 pm
Posts: 1970
Website: http://www.rwky.net
Location: Earth
What net-burst said is right, as for nginx on 0.0.0.0 that just means it's listening on all interfaces don't worry about it it's normal.

_________________
Paid support
How to ask for help
1. Give details of your problem
2. Post any errors
3. Post relevant logs.
4. Don't hide details i.e. your domain, it just makes things harder
5. Be polite or you'll be eaten by a grue


Top
   
 Post subject:
PostPosted: Fri May 04, 2012 11:00 pm 
Offline
Senior Newbie

Joined: Wed Nov 23, 2011 11:01 am
Posts: 16
ICQ: 35213257
Website: http://freshma.de/
Location: Saint Louis, MO
I looked into /etc/php5/fpm/main.conf yet there isn't a line starting with listen, did a search and the only result was in the comments for Multiple pools.

I dug around a little on the related info and php-fpm, loopback and the likes and followed the concept a bit from http://www.howtoforge.com/installing-ng ... u-11.10-p2 (despite this being a page for a newer version).

Speaking of which, I'm prepping backups incase an upgrade goes completely wrong for me. I have my current Linode set up with three partitions, but cannot find a way to access the third partition I created for rsync backup purposes, I'd love to be able to utilize that to "clone" my current server configs and such in case something went awry, we'll see if I figure that one out.

Back to this issue as I've gone off topic. When I try to restart php-fpm I get this, which seems as though something could be awry elsewhere.

Code:
/etc/init.d/php5-fpm restart
 * Stopping PHP5 FPM...                                                                                          [ OK ]
 * Starting PHP5 FPM...                                                                                                 PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/xml.so' - /usr/lib/php5/20090626+lfs/xml.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  Module 'curl' already loaded in Unknown on line 0
PHP Warning:  Module 'xmlrpc' already loaded in Unknown on line 0
May 04 21:50:56.678053 [WARNING] [pool www] pm.start_servers is not set. It's been set to 3.

_________________
Newbie to Linode, excited to be here!


Top
   
 Post subject:
PostPosted: Sat May 05, 2012 6:46 am 
Offline
Senior Member

Joined: Sun Mar 07, 2010 7:47 pm
Posts: 1970
Website: http://www.rwky.net
Location: Earth
You can turn on linode backups to backup your node before upgrading it's probably the easiest solution (and not expensive) you can submit a ticket to turn them off when you don't need them anymore.

As for php-fpm what's the contents of /etc/php5/fpm/main.conf

_________________
Paid support
How to ask for help
1. Give details of your problem
2. Post any errors
3. Post relevant logs.
4. Don't hide details i.e. your domain, it just makes things harder
5. Be polite or you'll be eaten by a grue


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group