A-A+

配置Magento在Nginx中运行run Magento with Nginx

2012年08月28日 灵犀一指 配置Magento在Nginx中运行run Magento with Nginx已关闭评论 阅读 1,218 人 次

系统环境:CentOS5.0
Nginx版本:0.7.47
Magento版本:1.2.0.3
Nginx+MySQL+PHP环境是按照张宴的文章搭建的,只需作一点修改就可以让Magento跑起来

1、修改fcgi.conf
vi /usr/local/webserver/nginx/conf/fcgi.conf

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
修改为
#fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
#fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
2、修改nginx.conf
mv /usr/local/webserver/nginx/conf/nginx.conf /usr/local/webserver/nginx/conf/nginx.conf.OLD
vi /usr/local/webserver/nginx/conf/nginx.conf
添加以下内容:

[php]
user  www www;
worker_processes 8;
pid        /usr/local/webserver/nginx/nginx.pid;
worker_rlimit_nofile 51200;

events
{
  use epoll;
  worker_connections 51200;
}

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

  #charset  gb2312;

  server_names_hash_bucket_size 128;
  client_header_buffer_size 32k;
  large_client_header_buffers 4 32k;
  client_max_body_size 8m;

  sendfile on;
  tcp_nopush     on;

  keepalive_timeout 60;

  tcp_nodelay on;

  fastcgi_connect_timeout 300;
  fastcgi_send_timeout 300;
  fastcgi_read_timeout 300;
  fastcgi_buffer_size 64k;
  fastcgi_buffers 4 64k;
  fastcgi_busy_buffers_size 128k;
  fastcgi_temp_file_write_size 128k;

  gzip on;
  gzip_min_length  1k;
  gzip_buffers     4 16k;
  gzip_http_version 1.0;
  gzip_comp_level 2;
  gzip_types       text/plain application/x-javascript text/css application/xml;
  gzip_vary on;

  #limit_zone  crawler  $binary_remote_addr  10m;
server {
    listen   80;
    server_name  www.example.com;
    index index.html index.htm index.php;
    root  /data0/htdocs/www;
    error_log  /data1/logs/nginx_error.log;

    # media
    location ~* \.(png|gif|jpg|jpeg|css|js|swf|ico)$ {
        root   /data0/htdocs/www/;
        access_log off;
        expires 30d;
    }

    # 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 /data0/htdocs/www$fastcgi_script_name;
        include fcgi.conf;
    }
    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  /data0/htdocs/www$fastcgi_script_name;
        include fcgi.conf;
        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 /data0/htdocs/www/index.php;
        include fcgi.conf;
    }
}
}

[/php]

请根据实际情况进行修改,如果按照张宴文章配置,则只需将server_name修改为你自己的域名,保存退出。
重启Nginx,使配置生效
kill -HUP `cat /usr/local/webserver/nginx/nginx.pid`
经过以上设置,就可以使Magento跑在Nginx上了。
主要参考文章:
http://blog.s135.com/nginx_php_v4/
http://www.magentocommerce.com/boards/viewthread/7931/
http://www.ruby-forum.com/topic/177888

评论已关闭!