宝塔面板安装Magento2伪静态nginx重写规则
啥也不说先直接上代码
location / {
index index.html index.php; ## Allow a static html file to be shown first
try_files $uri $uri/ @handler;
expires 30d;
}
location /var/export/ { ## Allow admins only to view export folder
auth_basic "Restricted"; ## Message shown in login window
auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword
autoindex on;
}
location /. { ## Disable .htaccess and other hidden files
return 404;
}
location @handler { ## Magento uses a common front handler
rewrite / /index.php;
}
location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
rewrite ^(.*.php)/ $1 last;
}
我用的环境是?
php7.0.33; nginx1.16.0; MySQL 10.1.39-MariaDB;
magento版本:2.1.16
php7.1.4; nginx1.16.0; MySQL 10.1.39-MariaDB;
magento版本:2.1.17
mysql建议5.6以上
建议去git上面挨个看magento版本,每个版本都有对应环境要求.
执意要使用你的php版本,其实高版本的话问题不大,强制在magento里面修改允许php版本即可这里就不多说这个内容.
以下是具体操作
建立好站点,我们无法打开后台或者浏览商城,这是因为地址重写等问题.我们现在加入这些规则,规则左右在后面注释了.清晰明了.
操作: 网站->[你的网站名]->伪静态->修改0.当前,复制规则->保存(可自己另存为模板"magento2")
一开始刚接触那几天坑多,现在反正是怎么装怎么顺利,有空多看下zendframe,M2里面的架构.
可能遇到的坑
安装问题有个坑也务必注意一下,就是Web Configuration
最后
宝塔论坛原贴链接(也是我写的)
转载麻烦原文链接就好,顺便给小弟多点赞和评论