yii2的简单安装
每到一个公司都有自己的php框架,目前没有和开源完全重合的。
一直想完整的读一个开源的php框架的代码,开源框架太多,最近选取yii作为分析对象
通过composer安装yii2
1 安装composer 我使用的是brew安装的
2 composer create-project –prefer-dist –stability=dev yiisoft/yii2-app-advanced ../yii2test
create-project创建一个项目
--prefer-dist: 当有可用的包时,从 dist 安装。
--stability 资源包的最低稳定版本,默认为 stable。
yiisoft/yii2-app-advanced 软件的名称
软件的路径../yii2test
安装时需要token,在github生成你的token https://github.com/settings/tokens
composer 安装yii2 安装了很多我不需要的,而且也不清楚代码里面的依赖
下载tar包
直接在http://www.yiiframework.com/download/下载下面地址的tar包
https://github.com/yiisoft/yii2/releases/download/2.0.10/yii-basic-app-2.0.10.tgz
yii运行环境准备
配置host
127.0.0.1 framework.yii2.kang.com
配置nginx
server {
listen 80;
server_name framework.yii2.kang.com;
access_log /Users/kang/Documents/var/log/access.log;
#root /Users/kang/Documents/phpProject/studyphp/framework/yaf;
root /Users/kang/Documents/phpProject/studyphp/framework/yii2;
index index.php index.html index.htm;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
include fastcgi.conf;
}
if (!-e $request_filename) {
rewrite ^/(.*) /index.php/$1 last;
}
}
运行 http://framework.yii2.kang.com/requirements.php
记得在config里面加上cookieValidationKey即可
yii2的安装告一段落,下面我们开始下一段旅程。