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. c——动态数组

    动态数组的实现 #include<stdio.h> #include<stdlib.h> int main(){ int i,n,*a; scanf("%d" ...

  2. redis 远程连接出错的解决办法

    1. 配置防火墙端口 redis系统的默认端口是6379端口. # 打开端口 $ firewall-cmd --zone=public --add-port=6379/tcp --permanent ...

  3. python------面向对象进阶 Socket网络编程

    一.Socket网络编程 1.七层模型,亦称OSI(Open System Interconnection)参考模型,是参考模型是国际标准化组织(ISO)制定的一个用于计算机或通信系统间互联的标准体系 ...

  4. 2.python发展历程

    创始人:吉多·范罗苏姆于1989年圣诞节在阿姆斯特丹编写 python分为: python 2.X python 3.X 使用python的公司: 豆瓣.BT.Dropbox.YouTube.Quor ...

  5. oracle-taf

    http://blog.sina.com.cn/s/blog_48567d850102wck0.html配置目标:把RAC系统配置为“主-备”模式,即平时所有连接都在rac01这个节点上,当rac01 ...

  6. 原生JS怎样给div添加链接

    html: <div href="http://www.atigege.com" target="_blank">个人网站</div> ...

  7. py-day3-4 python 匿名函数

    # 匿名函数 lamdba name = 'xiaoma' f = lambda x:x+'jun' res = f(name) print('匿名函数的运行结果:',res) 匿名函数的运行结果: ...

  8. RDO快速部署OpenStack

    RDO快速部署OpenStack 1.RDO是什么 RDO是红帽Red Hat Enterprise Linux OpenStack Platform的社区版,类似RHEL和Fedora,RHEV和o ...

  9. PHP-ML机器学习库之安装篇

    1.PHP-ML库安装要求:PHP>=7.1 2.切换到项目的跟目录下,使用composer进行安装:composer require php-ai/php-ml 安装完成后的目录如下: 新建测 ...

  10. CentOS7 上学习使用docker

    一.CentOS7(64)上安装和使用docker的笔记. 1. 增加docker用户 sudo groupadd docker sudo useradd -g docker docker 2. 增加 ...