1.nginx配置 重写规则 修改访问模式为 http://wh.store/admin/index

文件位置: /home/wwwroot/default/yii2-app-basic/config/web.php

'urlManager' => [

'enablePrettyUrl' => true,

'showScriptName' => false,

'rules' => [

],

],

文件位置: /usr/local/nginx/conf/vhost/yz.store.conf

server

{

listen 80;

#listen [::]:80;

server_name yz.store ;

index index.html index.htm index.php default.html default.htm default.php;

root /home/wwwroot/default/yii2-app-basic/web;

    include none.conf;
#error_page 404 /404.html; # Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; } include enable-php.conf; access_log /home/wwwroot/default/yii2-app-basic/vagrant/nginx/log/y.net.access.log;
error_log /home/wwwroot/default/yii2-app-basic/vagrant/nginx/log/y.net.error.log; location / {
# Redirect everything that isn't a real file to index.php
try_files $uri $uri/ /index.php$is_args$args;
} # deny accessing php files for the /assets directory
location ~ ^/assets/.*\.php$ {
deny all;
} location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass unix:/var/run/php5-fpm.sock;
try_files $uri =404;
} location ~* /\. {
deny all;
} }

2. FastCGI sent in stderr: "PHP message: PHP Warning: require(): open_basedir restriction in effect.

修改nginx 配置 /usr/local/nginx/conf/fastcgi.conf # 禁用 重启服务器

#fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";

3.post方式不能访问 post 400 csrf json请求不到

禁用csrf 配置json请求

文件地址:/home/wwwroot/default/yii2-app-basic/config/web.php

'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => 'mark453100',
"enableCsrfValidation"=>false, #禁用csrf
"parsers" => [
'application/json' => 'yii\web\JsonParser', #支持json格式的请求
'text/json' => 'yii\web\JsonParser', #支持json格式的请求
], ]

控制器接收post方法

$request = Yii::$app->request;
$post = $request->post();
var_dump($post);

4.如何配置数据库和建立模型类

文件地址:/home/wwwroot/default/yii2-app-basic/config/db.php

<?php
return [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=192.168.1.125;dbname=h5_store',
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
'tablePrefix' => 'h5_', #表前缀
// Schema cache options (for production environment)
//'enableSchemaCache' => true,
//'schemaCacheDuration' => 60,
//'schemaCache' => 'cache',
];

Model类

文件位置:/home/wwwroot/default/yii2-app-basic/models/Product.php

<?php

namespace app\models;

use yii\db\ActiveRecord;

class Product extends ActiveRecord
{
const STATUS_INACTIVE = 0;
const STATUS_ACTIVE = 1; /**
* @return string AR 类关联的数据库表名称
*/
public static function tableName()
{
return '{{product}}';
}
}

yii2 basic版本的一些配置的更多相关文章

  1. AgileEAS.NET SOA 中间件平台5.2版本下载、配置学习(四):开源的Silverlight运行容器的编译、配置

    一.前言 AgileEAS.NET SOA 中间件平台是一款基于基于敏捷并行开发思想和Microsoft .Net构件(组件)开发技术而构建的一个快速开发应用平台.用于帮助中小型软件企业建立一条适合市 ...

  2. AgileEAS.NET SOA 中间件平台5.2版本下载、配置学习(三):配置ActiveXForm运行环境

    一.前言 AgileEAS.NET SOA 中间件平台是一款基于基于敏捷并行开发思想和Microsoft .Net构件(组件)开发技术而构建的一个快速开发应用平台.用于帮助中小型软件企业建立一条适合市 ...

  3. AgileEAS.NET SOA 中间件平台5.2版本下载、配置学习(二):配置WinClient分布式运行环境

    一.前言 AgileEAS.NET SOA 中间件平台是一款基于基于敏捷并行开发思想和Microsoft .Net构件(组件)开发技术而构建的一个快速开发应用平台.用于帮助中小型软件企业建立一条适合市 ...

  4. Yii2高级版本复制新项目出现问题解决(转)

    引用于 http://www.linuxidc.com/Linux/2015-02/114116.htm Yii2高级版本复制新项目会遇到下面的报错信息: exception 'yii\base\In ...

  5. 使用composer更新thinkphp5或则yii2的版本

    更新thinkphp5或则yii2的版本,我目前采用的是用composer去更新,小伙伴们如果有其他更好的办法更新,可以直接评论给我,不胜感激啊. 如果还没有安装 Composer ,你可以按 Com ...

  6. yii2的数据库读写分离配置

    简介 数据库读写分离是在网站遇到性能瓶颈的时候最先考虑优化的步骤,那么yii2是如何做数据库读写分离的呢?本节教程来给大家普及一下yii2的数据库读写分离配置. 两个服务器的数据同步是读写分离的前提条 ...

  7. 【内核】linux2.6版本内核编译配置选项(二)

    目录 Linux2.6版本内核编译配置选项(一):http://infohacker.blog.51cto.com/6751239/1203633 Linux2.6版本内核编译配置选项(二):http ...

  8. 【内核】linux2.6版本内核编译配置选项(一)

    Linux 2.6.19.x 内核编译配置选项简介 作者:金步国 版权声明 本文作者是一位自由软件爱好者,所以本文虽然不是软件,但是本着 GPL 的精神发布.任何人都可以自由使用.转载.复制和再分发, ...

  9. centos7: svbversion版本的安装配置+tortoisesvn登录验证

    centos7: svbversion版本的安装配置+tortoisesvn登录验证 命令工具:svnadmin create #创建版本库 hotcopy #版本库热备份 Islocks #打印所有 ...

随机推荐

  1. 如何利用 Git 与 GitHub 进行多人协作开发

    方法一:添加 Collaborators Collaborators 类似于Team模式. Repository的拥有者Owner 可以直接添加合作者到自己的仓库中, 让合作者拥有几乎等同拥有者的权限 ...

  2. Python之小练习

    1.1 2 3 4 5 6 7 8能组成多少个不同的两位数? count = 0for i in range(1,9): for V in range(1,9): if i != V: count+= ...

  3. 常见模块(四) os模块

    注: os模块是实现python程序对操作系统(operation system)的操作 1.对文件或者目录进行删除或者创建的相关操作 # os.rename("b"," ...

  4. 使用Blend设计出符合效果的WPF界面

    之前不会用blend,感觉好难的,但美工给出的效果自己有没办法实现,所以研究了一下blend,感觉没有想象中的那么难 废话不多说,开始界面设计 今天拿到美工给的一个界面效果图 这个界面说实话,还可以吧 ...

  5. java——慎用可变参数列表

    说起可变参数,我们先看下面代码段,对它有个直观的认识,下方的红字明确地解释了可变参数的意思: public class VarargsDemo{ static int sum(int... args) ...

  6. 使用 jest 测试 react component 的配置,踩坑。

    首先安装依赖 npm i jest -g npm i jest babel-jest identity-obj-proxy enzyme enzyme-adapter-react-15.4 react ...

  7. vim编辑Makefile如何使用Tab

    因为用vim编辑代码设置了Tab键为4个空格,但有时候我们需要编写Makefile,必须使用Tab,同时也不想设置set noexpandtab. 其实可以先Ctrl_v组合键,再按Tab键盘,这样我 ...

  8. win32网络模型之重叠I/O

    网上大部分重叠I/O的基本概念都讲得很清楚,但是大多讲得不是很深入,实际用起来很多问题.这里只对完成实例的通知进行讨论,对问题进行总结. 重叠IO异步读写后,在某一时刻"完成"后会 ...

  9. 关于Xilinx AXI Lite 源代码分析---自建带AXI接口的IP

    关于Xilinx AXI Lite 源代码分析---自建带AXI接口的IP 首先需要注意此处寄存器数量的配置,它决定了slv_reg的个数. 读写数据,即是对寄存器slv_reg进行操作: 关于AXI ...

  10. django路由系统URLS

    usrls: from django.contrib import admin from django.urls import path from cmbd import views from dja ...