Problem using Magento with nginx

Hello -

I have installed nginx + PHP-FPM and it is working perfectly for my
Drupal sites (nginx 0.6.33, PHP 5.2.6, FPM 0.5.9, Drupal 6.6, Debian
Etch).

Now I am trying to use Magento (1.2.1) with nginx, and I am getting the
error message “No input file specified.”

I have adapted the instructions for installing Magento on Debian Etch
here:

(omitting the steps involving Apache).

I have adapted the the nginx.conf files for Magento posted here:

http://www.magentocommerce.com/boards/viewthread.../viewthread/7931/#t29161
http://www.ruby-forum.com/topic/130700

My nginx.conf file looks like this:

user www-data www-data;
worker_processes 2;

error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

pid logs/nginx.pid;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

#log_format  main  '$remote_addr - $remote_user [$time_local]

$request ’
# '“$status” $body_bytes_sent “$http_referer” ’
# ‘“$http_user_agent” “$http_x_forwarded_for”’;

#access_log  logs/access.log  main;

sendfile        on;
#tcp_nopush     on;

keepalive_timeout  65;

gzip on;
gzip_comp_level 1; gzip_proxied any;
gzip_types text/plain
           text/html
           text/css
           application/x-javascript
           text/xml
           application/xml
           application/xml+rss
           text/javascript;

 ## Deny access to any host other than (www.)mydomain.com
server {
     server_name  _;  #default
     return 444;
 }

server {
listen 80;
server_name .mysubdom.mydom.net;

access_log  /usr/local/nginx/logs/mysubdom.access.log;
error_log   /usr/local/nginx/logs/mysubdom.error.log;

gzip on;
#gzip_comp_level 9;
gzip_min_length  1000;
gzip_proxied any;
gzip_types       text/plain application/xml text/html text/css

text/js application/x-javascript;

#error_page  404  /404.html;

# redirect server error pages to the static page /50x.html
error_page   500 502 503 504  /50x.html;
location = /50x.html {
  root   html;
}

# media
location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico|swf)$ {
  root /home/stefan/sources/magento/;
  access_log        off;
  expires           30d;
  break;
}


# pass the PHP scripts to FastCGI socket
location ~ \.php$ {
  fastcgi_pass   127.0.0.1:9000;
  fastcgi_index index.php;
  fastcgi_param  SCRIPT_NAME $fastcgi_script_name;
  fastcgi_param  SCRIPT_FILENAME

/home/stefan/sources/magento$fastcgi_script_name;
include /usr/local/nginx/conf/fastcgi_params;
}
location ^~ /js/proxy.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME
/home/stefan/sources/magento$fastcgi_script_name;
include /usr/local/nginx/conf/fastcgi_params;
access_log off;
expires 30d;
}
location / {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_NAME index.php;
fastcgi_param SCRIPT_FILENAME
/home/stefan/sources/magento/index.php;
include /usr/local/nginx/conf/fastcgi_params;
}
}

}

My file /usr/local/nginx/conf/fastcgi_params looks like this:

fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;

fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;

fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;

PHP only, required if PHP was built with --enable-force-cgi-redirect

fastcgi_param REDIRECT_STATUS 200;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

My Magento installation looks like this:

ls -l /home/stefan/sources/magento

total 112
drwxrwxr-x 3 root root 4096 2009-02-02 19:11 404
drwxrwxr-x 6 root root 4096 2009-02-02 19:11 app
-rw-rw-r-- 1 root root 1579 2009-02-02 14:16 cron.php
drwxrwxr-x 7 root root 4096 2009-02-02 19:11 downloader
-rw-rw-r-- 1 root root 1150 2009-02-02 14:16 favicon.ico
-rw-rw-r-- 1 root root 1892 2009-02-02 14:16 index.php
-rw-rw-r-- 1 root root 1901 2009-02-02 14:16 index.php.sample
-rw-rw-r-- 1 root root 6129 2009-02-02 14:16 install.php
drwxrwxr-x 10 root root 4096 2009-02-02 19:11 js
drwxrwxr-x 7 root root 4096 2009-02-02 19:11 lib
-rw-rw-r-- 1 root root 10421 2009-02-02 14:16 LICENSE_AFL.txt
-rw-rw-r-- 1 root root 10410 2009-02-02 14:16 LICENSE.txt
drwxrwxr-x 4 root www-data 4096 2009-02-02 19:11 media
-rwxrwxr-x 1 root root 2982 2009-02-02 14:16 pear
-rw-rw-r-- 1 root root 751 2009-02-02 14:16 php.ini.sample
drwxrwxr-x 2 root root 4096 2009-02-02 19:11 pkginfo
drwxrwxr-x 3 root root 4096 2009-02-02 19:11 report
drwxrwxr-x 5 root root 4096 2009-02-02 19:11 skin
-rw-rw-r-- 1 root root 14597 2009-02-02 14:16 STATUS.txt
drwxrwxr-x 2 root www-data 4096 2009-02-02 19:11 var

When I point my browser at http://mysubdom.dom.net, I get the message:

No input file specified.

Do you have any ideas what I am doing wrong here?

Thank you for any help.

  • Stefan S. Alexander

TYPO:

When I point my browser at http://mysubdom.dom.net, I get the message:

SHOULD SAY:
When I point my browser at http://mysubdom.MYdom.net, I get the message:

On Fri, Feb 06, 2009 at 07:09:02PM +0100, Stefan S. wrote:

I have adapted the instructions for installing Magento on Debian Etch
Home - Magento Forums
#error_log logs/error.log notice;
http {
sendfile on;
text/xml

gzip_min_length  1000;
}
# pass the PHP scripts to FastCGI socket
location ~ \.php$ {
  fastcgi_pass   127.0.0.1:9000;
  fastcgi_index index.php;
  fastcgi_param  SCRIPT_NAME $fastcgi_script_name;
  fastcgi_param  SCRIPT_FILENAME

/home/stefan/sources/magento$fastcgi_script_name;
include /usr/local/nginx/conf/fastcgi_params;
}

The /js/proxy.php location probably can be handled by ~ .php$ location.

location / {

fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;

PHP only, required if PHP was built with --enable-force-cgi-redirect

fastcgi_param REDIRECT_STATUS 200;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

You need to remove SCRIPT_FILENAME and SCRIPT_NAME parameters from
/usr/local/nginx/conf/fastcgi_params: they override the same ones
in locations.

I promise I’ve paid due diligence trying to solve this one through
Google, but just can’t come up with the solution (I’ve probably
overlooked something very simple).

In Apache, I can forward a captured variable from a RewriteCond check
like this:
RewriteCond %{QUERY_STRING} tag=(.)
RewriteRule ^fastsearch(.
) /tags/%1? [L,R=301]

but I can’t seem to find the nginx equivalent as the following doesn’t
work:
if ($query_string ~ "tag=(.)") {
rewrite ^/fastsearch.
/tags/%1? permanent;
}

My server admin is requiring that we run the stable version (0.6.35) so
I can’t use the $arg_PARAMETER introduced in 0.7.*.

What am I missing?

Chris

On Fri, Feb 06, 2009 at 02:53:25PM -0500, Chris Sturgill wrote:

but I can’t seem to find the nginx equivalent as the following doesn’t work:
if ($query_string ~ "tag=(.)") {
set $tag $1;
rewrite ^/fastsearch.
/tags/$tag? permanent;
}

Thank you much! I had tried putting $1 directly into the rewrite
without setting a separate variable, but got yelled at for not having a
matching term in the left-hand side of the rewrite equation. This
simple answer just solved several days of frustration!

On Fri, Feb 06, 2009 at 02:53:25PM -0500, Chris Sturgill wrote:

if ($query_string ~ "tag=(.)") {
rewrite ^/fastsearch.
/tags/%1? permanent;
}

My server admin is requiring that we run the stable version (0.6.35) so
I can’t use the $arg_PARAMETER introduced in 0.7.*.

What am I missing?

if ($query_string ~ "tag=(.)") {
set $tag $1;
rewrite ^/fastsearch.
/tags/$tag? permanent;
}

Igor S. wrote:

You need to remove SCRIPT_FILENAME and SCRIPT_NAME parameters from
/usr/local/nginx/conf/fastcgi_params: they override the same ones
in locations.

Thank you so much Igor - it worked!