【问题标题】:Nginx configuration with Magento 1.8Magento 1.8 的 Nginx 配置
【发布时间】:2011-05-20 04:40:47
【问题描述】:

有人知道如何在 nginx 服务器的配置文件中配置 server {} 吗? 我在下面有这样的东西:

server {
  server_name   local.com;

  root some_path;

  index index.php;

  #location / {
    #try_files $uri $uri/ index.php;
    #proxy_pass  http://127.0.0.1:9000;
  #}

  # set a nice expire for assets
  #location ~* "^.+\.(jpe?g|gif|css|png|js|ico|pdf|zip|tar|t?gz|mp3|wav|swf)$" {
  #  expires    max;
  #  add_header Cache-Control public;
  #}

  # the downloader has its own index.php that needs to be used
  #location ~* ^(/downloader|/js|/404|/report)(.*) {
  #  include fastcgi_params;
  #  fastcgi_index index.php;
  #  fastcgi_param  SCRIPT_FILENAME  $document_root$1/index.php$1;
  #  fastcgi_read_timeout 600;
  #  fastcgi_pass  127.0.0.1:9000;
  #}

  location ~* \.php {
    include               fastcgi_params;
    fastcgi_param         SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    fastcgi_read_timeout  18000;
    fastcgi_pass          127.0.0.1:9000;
  }

  #location ~* ^(/index.php)?(.*) {
  #  include               fastcgi_params;
  #  fastcgi_param         SCRIPT_FILENAME  $document_root/index.php$1;
  #  fastcgi_pass          127.0.0.1:9000;
  #  fastcgi_read_timeout  18000;
  #}

}

浏览器返回空白页,不执行 php...

编辑:

在使用 nginx 配置和 php 的东西花了一些时间后,我发现网站在某些情况下可以正常加载,而在某些情况下则不能...

例如: 我有两个相同的页面,但出于某种原因,首先加载的是一个魅力,其次是部分加载...

有时页面加载到一半...

Nginx 没有记录任何东西...

由于某种原因,当我尝试转到后端时,nginx 会使用后端 url 加载前端:/

有没有人可以给我提供其他的 magento 1.8 配置?

【问题讨论】:

    标签: mysql nginx fastcgi magento


    【解决方案1】:

    在回答后面关于 MAGE_RUN_CODE 的问题时,您可以使用 nginx 映射来完成。见:Coeus Blue Blog Post

    【讨论】:

      【解决方案2】:

      好的,这不是内存或数据库问题,而是... IonCube 问题... 我正在调试核心类,发现脚本在 Enteprise Modules 上停止并且... 如果您没有安装 IonCube只是简单地显示空白页。

      但是,现在 Magento 返回 404: Page not found...

      谢谢,伙计们的帮助,如果您对第二个问题有任何建议,请随时在此处发布:)

      应用小修复后:

      /* Store or website code */
      $mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
      /* Run store or run website */
      $mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
      Mage::run('', 'store'); //<-this
      //Mage::run($mageRunCode, $mageRunType);
      

      Front 和 Back 正在加载,但控制器有问题...但不会太久!

      A 如果我输入 url /admin nginx 将返回 Input file not found,但是当我输入 index.php/admin 它加载...部分。这是重写和服务器变量的问题。

      编辑:

      我赢了! iconv 没有安装...现在一切正常,除了重写...

      总结: 我需要找到一种方法来正确获取 index.php 文件的服务器 var 并将 index.php 重写为 /

      谢谢帮助!

      【讨论】:

      • 位置 / { 索引 index.php; if (!-e $request_filename) { rewrite ^(.+)$ /index.php last; } try_files $uri $uri/ index.php; } 把它从 index.php 重定向到 /
      • 对于服务器变量:fastcgi_param MAGE_RUN_CODE 代码; fastcgi_param MAGE_RUN_TYPE 类型;然后我们可以在代码中使用 $_SERVER['MAGE_RUN_CODE'],因为它没有工作,因为我在 nginx 配置方面遇到了其他问题。
      【解决方案3】:

      index 指令之后(其实在哪里都无所谓,只是为了便于阅读)添加一个try_files 指令。

      try_files $uri $uri/ /index.php;
      

      偶然我写了一个更完整的指南:Configuring nginx for Magento

      【讨论】:

      • 谢谢,帮助您的教程阐明了 nginx 中的一些要点,但我仍然无法强制 nginx 在我的域中正确执行文件。
      • 我之前没看注释掉的部分,错过了你之前做过try_files。
      • 如果 PHP 文件正确执行但内存不足,它们会返回空白页。 Magento 会发生这种情况,因为它会覆盖正常的错误报告并且非常占用内存。您是否尝试过仅使用 &lt;?php phpinfo(); 创建文件并访问该文件?
      • 我确实将 phpinfo() 放在了 index.php 的开头,但它仍然是空白页。有趣的是,当我第一次安装 nginx 时,执行 Mage::run(...) 之前的所有内容,例如:phpinfo()
      • 对不起,我不知道空白页的另一个原因。如果还有其他问题,它会给出“Bad Gateway”或“Input file not specified”错误。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-15
      • 2015-09-05
      相关资源
      最近更新 更多