当前位置:论坛首页 > Linux面板 > 建议

关于magento2的nginx伪静态(重写规则)

发表在 Linux面板2019-6-4 18:16 [复制链接] 6 7481

本帖最后由 keyboardman 于 2019-6-5 10:39 编辑

由于接触到magento2项目,想试试宝塔装,网上没有相关的伪静态代码提供,于是我自己写了一份,经过测试可用
  1. 环境:php7.0.33; nginx1.16.0; MySQL 10.1.39-MariaDB;
  2. magento版本:2.1.2
复制代码
接下来附上我的代码:
  1. location / {
  2.         index index.html index.php; ## Allow a static html file to be shown first
  3.         try_files $uri $uri/ @handler;
  4.         expires 30d;
  5.     }

  6.     location /var/export/ { ## Allow admins only to view export folder
  7.         auth_basic           "Restricted"; ## Message shown in login window
  8.         auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword
  9.         autoindex            on;
  10.     }
  11.       location  /. { ## Disable .htaccess and other hidden files
  12.         return 404;
  13.     }

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

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

复制代码
官方也可以采纳下,顺提一下,伪静态选项多了,可以做个分类目录,然后选择对应的框架哦!

使用道具 举报 只看该作者 回复
发表于 2019-6-4 18:19:22 | 显示全部楼层
不错的建议哈
使用道具 举报 回复 支持 反对
发表于 2019-6-5 10:09:19 | 显示全部楼层
感谢您的分享和建议!
使用道具 举报 回复 支持 反对
发表于 2019-6-15 10:59:51 | 显示全部楼层
本帖最后由 keyboardman 于 2019-6-15 11:03 编辑

安装问题有个坑也务必注意一下,就是Web Configuration有时候会有问题,自定义选项中可以去除自动添加规则重写的选项再装一次试试
使用道具 举报 回复 支持 反对
发表于 2019-6-15 11:07:24 | 显示全部楼层
装环境前请仔细看要求,php版本差一点都不行的,mysql建议5.6以上,还有宝塔的php是可以升级的,
不要浪费时间一个一个试,或者你技术过得去,直接改magento框架内php版本要求,强制允许你自己想要的版本
使用道具 举报 回复 支持 反对
发表于 2019-6-24 14:51:08 | 显示全部楼层
现在宝塔面板已经支持Magento 2了吗?需要配置什么样的环境?哪位高手可以提供一份安装流程,感谢!
使用道具 举报 回复 支持 反对
发表于 2022-5-16 12:09:59 | 显示全部楼层
这个设置如果开启SSL Https 后台无法打开
使用道具 举报 回复 支持 反对
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

企业版年付运维跟进群

普通问题处理

论坛响应时间:72小时

问题处理方式:排队(仅解答)

工作时间:白班:9:00 - 18:00

紧急问题处理

论坛响应时间:10分钟

问题处理方式:1对1处理(优先)

工作时间:白班:9:00 - 18:00

工作时间:晚班:18:00 - 24:00

立即付费处理
快速回复 返回顶部 返回列表