thinkcmf5与宝塔
1.安装宝塔:https://www.bt.cn/download/linux.html
2.宝塔手册:https://www.kancloud.cn/chudong/bt2017/424204
3.安装拓展:软件商店->安装拓展->重启服务
4.open_basedir:网站->设置->网站目录->防跨站
5.数据库授权:grant all privileges on *.* to root@'%' identified by "密码";FLUSH PRIVILEGES;
6.iptables -F;systemctl stop firewalld;setenforce 0;
7.thinkcmf手册:https://www.kancloud.cn/thinkcmf/doc5_1/957737
8.api文件夹和app文件夹是并列关系,区分它们是依考nginx配置
location / {
index index.php index.html index.htm;
#如果请求既不是一个文件,也不是一个目录,则执行一下重写规则
if (!-e $request_filename)
{
#地址作为将参数rewrite到index.php上。
rewrite ^/(.*)$ /index.php?s=$1;
#若是子目录则使用下面这句,将subdir改成目录名称即可。
#rewrite ^/subdir/(.*)$ /subdir/index.php?s=$1;
}
}
location /api/ {
index index.php index.html index.htm;
#如果请求既不是一个文件,也不是一个目录,则执行一下重写规则
if (!-e $request_filename)
{
#若是子目录则使用下面这句,将subdir改成目录名称即可。
rewrite ^/api/(.*)$ /api.php?s=$1;
}
}
包含公共HTML:https://www.kancloud.cn/thinkcmf/doc5_1/957843
<include file="blog@blog_nav"/>
横向nav标签,与自动标记active
<ul class="nav nav-tabs">
<li><a href="/blog/admin_index/index.html">角色管理</a></li>
<li><a href="/blog/admin_index/edit.html">添加角色</a></li>
</ul>
<script>
$(".nav-tabs > li > a[href='"+window.location.pathname+"']").parent().addClass('active')
</script>
注:登录后台后,自动跳转至前台解决方案。
找到/application/Admin/Controller/PublicController.class.php
将27-31行去除:
$loginAllowed = session("__LOGIN_BY_CMF_ADMIN_PW__");
if (empty($loginAllowed)) {
//$this->error('非法登录!', cmf_get_root() . '/');
return redirect(cmf_get_root() . "/");
}
找到37-38
session("__SP_ADMIN_LOGIN_PAGE_SHOWED_SUCCESS__", true);
$result = hook_one('admin_login');
中间加一行
session("__SP_ADMIN_LOGIN_PAGE_SHOWED_SUCCESS__", true);
session("__LOGIN_BY_CMF_ADMIN_PW__", 1);
$result = hook_one('admin_login');
替换后就可以正常登陆了(^-^)V