yii2 basic版本的一些配置
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版本的一些配置的更多相关文章
- AgileEAS.NET SOA 中间件平台5.2版本下载、配置学习(四):开源的Silverlight运行容器的编译、配置
一.前言 AgileEAS.NET SOA 中间件平台是一款基于基于敏捷并行开发思想和Microsoft .Net构件(组件)开发技术而构建的一个快速开发应用平台.用于帮助中小型软件企业建立一条适合市 ...
- AgileEAS.NET SOA 中间件平台5.2版本下载、配置学习(三):配置ActiveXForm运行环境
一.前言 AgileEAS.NET SOA 中间件平台是一款基于基于敏捷并行开发思想和Microsoft .Net构件(组件)开发技术而构建的一个快速开发应用平台.用于帮助中小型软件企业建立一条适合市 ...
- AgileEAS.NET SOA 中间件平台5.2版本下载、配置学习(二):配置WinClient分布式运行环境
一.前言 AgileEAS.NET SOA 中间件平台是一款基于基于敏捷并行开发思想和Microsoft .Net构件(组件)开发技术而构建的一个快速开发应用平台.用于帮助中小型软件企业建立一条适合市 ...
- Yii2高级版本复制新项目出现问题解决(转)
引用于 http://www.linuxidc.com/Linux/2015-02/114116.htm Yii2高级版本复制新项目会遇到下面的报错信息: exception 'yii\base\In ...
- 使用composer更新thinkphp5或则yii2的版本
更新thinkphp5或则yii2的版本,我目前采用的是用composer去更新,小伙伴们如果有其他更好的办法更新,可以直接评论给我,不胜感激啊. 如果还没有安装 Composer ,你可以按 Com ...
- yii2的数据库读写分离配置
简介 数据库读写分离是在网站遇到性能瓶颈的时候最先考虑优化的步骤,那么yii2是如何做数据库读写分离的呢?本节教程来给大家普及一下yii2的数据库读写分离配置. 两个服务器的数据同步是读写分离的前提条 ...
- 【内核】linux2.6版本内核编译配置选项(二)
目录 Linux2.6版本内核编译配置选项(一):http://infohacker.blog.51cto.com/6751239/1203633 Linux2.6版本内核编译配置选项(二):http ...
- 【内核】linux2.6版本内核编译配置选项(一)
Linux 2.6.19.x 内核编译配置选项简介 作者:金步国 版权声明 本文作者是一位自由软件爱好者,所以本文虽然不是软件,但是本着 GPL 的精神发布.任何人都可以自由使用.转载.复制和再分发, ...
- centos7: svbversion版本的安装配置+tortoisesvn登录验证
centos7: svbversion版本的安装配置+tortoisesvn登录验证 命令工具:svnadmin create #创建版本库 hotcopy #版本库热备份 Islocks #打印所有 ...
随机推荐
- Apache ZooKeeper 服务启动源码解释
转载:https://www.ibm.com/developerworks/cn/opensource/os-cn-zookeeper-code/ 本文首先讲解了 Apache ZooKeeper 服 ...
- 100道JS构造函数面试题
1. var User = { count: 1, getCount: function () { return this.count; } }; console.log(User.getCount( ...
- mysql下载以及安装
因为xampp怎么都连接不上mysql,我感觉有可能是因为装mysql的时候试了很多次才安装成功,之前的mysql没有卸载干净造成的,今天把mysql卸载干净,又重新安装配置环境,但是还是连接不上,然 ...
- 【转】利用Boost.Python将C++代码封装为Python模块
用Boost.Python将C++代码封装为Python模块 一. 基础篇 借助Boost.Python库可以将C/C++代码方便.快捷地移植到python模块当中,实现对python模块的扩 ...
- TCP TIME_WAIT过多的解决方法
总结: 最合适的解决方案是增加更多的四元组数目,比如,服务器监听端口,或服务器IP,让服务器能容纳足够多的TIME-WAIT状态连接.在我们常见的互联网架构中(NGINX反代跟NGINX,NGINX跟 ...
- 04-模拟String去除空格trim()方法
/** * 模拟String去除左右两边空格 * @param str */ public static String trim(String str) { char[] list = str.toC ...
- H5的本地存储技术及其与Cookie的比较
第一部分: H5的本地存储技术 HTML5 提供了两种在客户端存储数据的新方法.先看下面的例子: 例1:var mySelection = {name:"car", amount: ...
- react购物车
import React, { Component } from 'react'; import {Tabs} from './Tabs' import 'whatwg-fetch' im ...
- Sklearn (一) 监督学习
本系列博文是根据SKlearn的一个学习小结,并非原创! 1.直接学习TensorFlow有点不知所措,感觉需要一些基础知识做铺垫. 2.之前机器学习都是理论<Ng机器学习基础>+底层 ...
- 定位JVM内存溢出问题思路总结
JVM的内存溢出问题,是个常见而有时候有非常难以定位的问题.定位内存溢出问题常见方法有很多,但是其实很多情况下可供你选择的有效手段非常有限.很多方法在一些实际场景下没有实用价值.这里总结下我的一些定位 ...