VPS侦探论坛

 找回密码
 注册
查看: 6505|回复: 7

网店程序magento提供的nginx.conf.sample,如何修改成lnmp识别的?

[复制链接]
发表于 2015-11-29 10:16:43 | 显示全部楼层 |阅读模式

尝试修改貌似都失败了

# Magento Vars
# set $MAGE_ROOT /path/to/magento/root;
# set $MAGE_MODE default; # or production or developer
#
# Example configuration:
# upstream fastcgi_backend {
#    # use tcp connection
#    # server  127.0.0.1:9000;
#    # or socket
#    server   unix:/var/run/php5-fpm.sock;
# }
# server {
#    listen 80;
#    server_name mage.dev;
#    set $MAGE_ROOT /var/www/magento2;
#    set $MAGE_MODE developer;
#    include /vagrant/magento2/nginx.conf.sample;
# }


root $MAGE_ROOT/pub;

index index.php;
autoindex off;
charset off;

add_header 'X-Content-Type-Options' 'nosniff';
add_header 'X-XSS-Protection' '1; mode=block';

location /setup {
    root $MAGE_ROOT;
    location ~ ^/setup/index.php {
        fastcgi_pass   fastcgi_backend;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    location ~ ^/setup/(?!pub/). {
        deny all;
    }

    location ~ ^/setup/pub/ {
        add_header X-Frame-Options "SAMEORIGIN";
    }
}

location /update {
    root $MAGE_ROOT;

    location ~ ^/update/index.php {
        fastcgi_split_path_info ^(/update/index.php)(/.+)$;
        fastcgi_pass   fastcgi_backend;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param  PATH_INFO        $fastcgi_path_info;
        include        fastcgi_params;
    }

    # deny everything but index.php
    location ~ ^/update/(?!pub/). {
        deny all;
    }

    location ~ ^/update/pub/ {
        add_header X-Frame-Options "SAMEORIGIN";
    }
}

location / {
    try_files $uri $uri/ /index.php?$args;
}

location /pub {
    location ~ ^/pub/media/(downloadable|customer|import|theme_customization/.*\.xml) {
        deny all;
    }
    alias $MAGE_ROOT/pub;
    add_header X-Frame-Options "SAMEORIGIN";
}

location /static/ {
    if ($MAGE_MODE = "production") {
        expires max;
    }
    location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
        add_header Cache-Control "public";
        add_header X-Frame-Options "SAMEORIGIN";
        expires +1y;

        if (!-f $request_filename) {
            rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
        }
    }
    location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
        add_header Cache-Control "no-store";
        add_header X-Frame-Options "SAMEORIGIN";
        expires    off;

        if (!-f $request_filename) {
           rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
        }
    }
    if (!-f $request_filename) {
        rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
    }
    add_header X-Frame-Options "SAMEORIGIN";
}

location /media/ {
    try_files $uri $uri/ /get.php?$args;

    location ~ ^/media/theme_customization/.*\.xml {
        deny all;
    }

    location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
        add_header Cache-Control "public";
        add_header X-Frame-Options "SAMEORIGIN";
        expires +1y;
        try_files $uri $uri/ /get.php?$args;
    }
    location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
        add_header Cache-Control "no-store";
        add_header X-Frame-Options "SAMEORIGIN";
        expires    off;
        try_files $uri $uri/ /get.php?$args;
    }
    add_header X-Frame-Options "SAMEORIGIN";
}

location /media/customer/ {
    deny all;
}

location /media/downloadable/ {
    deny all;
}

location /media/import/ {
    deny all;
}

location ~ cron\.php {
    deny all;
}

location ~ (index|get|static|report|404|503)\.php$ {
    try_files $uri =404;
    fastcgi_pass   fastcgi_backend;

    fastcgi_param  PHP_FLAG  "session.auto_start=off \n suhosin.session.cryptua=off";
    fastcgi_param  PHP_VALUE "memory_limit=256M \n max_execution_time=600";
    fastcgi_read_timeout 600s;
    fastcgi_connect_timeout 600s;
    fastcgi_param  MAGE_MODE $MAGE_MODE;

    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include        fastcgi_params;
}
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2015-11-29 22:02:01 | 显示全部楼层


magento的直接修改下面的配置就行,域名,网站目录替换为你自己的
  1. upstream fastcgi_backend {
  2.     server   unix:/tmp/php-cgi.sock;
  3. }
  4. server {
  5.     listen 80;
  6.     server_name 域名;
  7.     set $MAGE_ROOT 网站目录;
  8.     set $MAGE_MODE default;

  9.         root $MAGE_ROOT/pub;

  10.         index index.php;
  11.         autoindex off;
  12.         charset off;

  13.         add_header 'X-Content-Type-Options' 'nosniff';
  14.         add_header 'X-XSS-Protection' '1; mode=block';

  15.         location /setup {
  16.                 root $MAGE_ROOT;
  17.                 location ~ ^/setup/index.php {
  18.                         fastcgi_pass   fastcgi_backend;
  19.                         fastcgi_index  index.php;
  20.                         fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
  21.                         include        fastcgi_params;
  22.                 }

  23.                 location ~ ^/setup/(?!pub/). {
  24.                         deny all;
  25.                 }

  26.                 location ~ ^/setup/pub/ {
  27.                         add_header X-Frame-Options "SAMEORIGIN";
  28.                 }
  29.         }

  30.         location /update {
  31.                 root $MAGE_ROOT;

  32.                 location ~ ^/update/index.php {
  33.                         fastcgi_split_path_info ^(/update/index.php)(/.+)$;
  34.                         fastcgi_pass   fastcgi_backend;
  35.                         fastcgi_index  index.php;
  36.                         fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
  37.                         fastcgi_param  PATH_INFO        $fastcgi_path_info;
  38.                         include        fastcgi_params;
  39.                 }

  40.                 # deny everything but index.php
  41.                 location ~ ^/update/(?!pub/). {
  42.                         deny all;
  43.                 }

  44.                 location ~ ^/update/pub/ {
  45.                         add_header X-Frame-Options "SAMEORIGIN";
  46.                 }
  47.         }

  48.         location / {
  49.                 try_files $uri $uri/ /index.php?$args;
  50.         }

  51.         location /pub {
  52.                 location ~ ^/pub/media/(downloadable|customer|import|theme_customization/.*\.xml) {
  53.                         deny all;
  54.                 }
  55.                 alias $MAGE_ROOT/pub;
  56.                 add_header X-Frame-Options "SAMEORIGIN";
  57.         }

  58.         location /static/ {
  59.                 if ($MAGE_MODE = "production") {
  60.                         expires max;
  61.                 }
  62.                 location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
  63.                         add_header Cache-Control "public";
  64.                         add_header X-Frame-Options "SAMEORIGIN";
  65.                         expires +1y;

  66.                         if (!-f $request_filename) {
  67.                                 rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
  68.                         }
  69.                 }
  70.                 location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
  71.                         add_header Cache-Control "no-store";
  72.                         add_header X-Frame-Options "SAMEORIGIN";
  73.                         expires    off;

  74.                         if (!-f $request_filename) {
  75.                            rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
  76.                         }
  77.                 }
  78.                 if (!-f $request_filename) {
  79.                         rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
  80.                 }
  81.                 add_header X-Frame-Options "SAMEORIGIN";
  82.         }

  83.         location /media/ {
  84.                 try_files $uri $uri/ /get.php?$args;

  85.                 location ~ ^/media/theme_customization/.*\.xml {
  86.                         deny all;
  87.                 }

  88.                 location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
  89.                         add_header Cache-Control "public";
  90.                         add_header X-Frame-Options "SAMEORIGIN";
  91.                         expires +1y;
  92.                         try_files $uri $uri/ /get.php?$args;
  93.                 }
  94.                 location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
  95.                         add_header Cache-Control "no-store";
  96.                         add_header X-Frame-Options "SAMEORIGIN";
  97.                         expires    off;
  98.                         try_files $uri $uri/ /get.php?$args;
  99.                 }
  100.                 add_header X-Frame-Options "SAMEORIGIN";
  101.         }

  102.         location /media/customer/ {
  103.                 deny all;
  104.         }

  105.         location /media/downloadable/ {
  106.                 deny all;
  107.         }

  108.         location /media/import/ {
  109.                 deny all;
  110.         }

  111.         location ~ cron\.php {
  112.                 deny all;
  113.         }

  114.         location ~ (index|get|static|report|404|503)\.php$ {
  115.                 try_files $uri =404;
  116.                 fastcgi_pass   fastcgi_backend;

  117.                 fastcgi_param  PHP_FLAG  "session.auto_start=off \n suhosin.session.cryptua=off";
  118.                 fastcgi_param  PHP_VALUE "memory_limit=256M \n max_execution_time=600";
  119.                 fastcgi_read_timeout 600s;
  120.                 fastcgi_connect_timeout 600s;
  121.                 fastcgi_param  MAGE_MODE $MAGE_MODE;

  122.                 fastcgi_index  index.php;
  123.                 fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
  124.                 include        fastcgi_params;
  125.         }
  126. }
复制代码
除此之外还需要额外安装intl、xsl的php模块及composer、去掉一个proc_open、proc_get_status的禁用函数
网站目录composer install 一下
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2015-11-30 13:35:02 | 显示全部楼层

回复 2# 的帖子


感谢军哥,太感谢了
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2015-11-30 15:13:44 | 显示全部楼层



还是装不上,空白一片
在lamp我有成功安装,intl,xsl也都能装好,lnmp下不行
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2015-11-30 20:11:31 | 显示全部楼层

可能还有其他问题,如权限等

前段时间我已经使用lnmp 1.3的php 5.5和5.6上测试过magento2了,没有问题,但需要使用命令进行安装

军哥运维代购:http://shop63846532.taobao.com/

发表于 2015-12-1 08:27:28 | 显示全部楼层

回复 5# 的帖子


军哥,在官网下载的安装确实不行,麻烦军哥查查啥问题,已经反复测试过多次,在LNMP下都无法运行,实在是查不出来哪里有问题。
发表于 2015-12-1 13:13:15 | 显示全部楼层

回复 6# 的帖子


我们没法给你查,具体你可以看看magento2目录下好像report里面就有每次出错的日志信息

我们已经测过过很多次
修改hosts
104.251.225.213 m2test.com
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2015-12-1 14:06:24 | 显示全部楼层

回复 5# 的帖子


的确是文件权限问题,用命令行,我也成功安装,然而前台和后台均打不开,500错误。
把所有文件权限改为777,就打开了

ps:所有文件权限都是777,肯定是不好的
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-4-19 15:05 , Processed in 0.033877 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表