Yii初始化安装
1. 直接下载源码包:
C/C++ Code复制内容到剪贴板
- #基础版
- wget https://github.com/yiisoft/yii2/releases/download/2.0.9/yii-basic-app-2.0.9.tgz
- #完整版
- wget https://github.com/yiisoft/yii2/releases/download/2.0.9/yii-advanced-app-2.0.9.tgz
下载解压后,进行下面的【初始化】
2. 通过composer安装(建议)
windows安装composer文件
安装好以后CMD输入:composer -V
1,设置composer从中国镜像下载,否则会很慢:
C/C++ Code复制内容到剪贴板
- composer config -g repo.packagist composer https://packagist.phpcomposer.com
2,设置GitHub的TOKEN
先登录你的github,进入个人中心,先左侧菜单最下面一项:【Developer settings 】>【Personal access tokens】,创建一个自己的token:
C/C++ Code复制内容到剪贴板
- composer config -g github-oauth.github.com e4cfb6fec0ebd876d42818df08db47fe7511b35e 换成你的token
3,安装Composer Asset插件
C/C++ Code复制内容到剪贴板
- composer global require "fxp/composer-asset-plugin:^1.2.0"
4,安装YII应用程序模板
C/C++ Code复制内容到剪贴板
- #完整版
- composer create-project yiisoft/yii2-app-advanced advanced 2.0.9
- #基础版
- composer create-project yiisoft/yii2-app-basic basic 2.0.9
初始化:
完整版下载完成后,进入advanced,执行init初始化。基础版不需要。
C/C++ Code复制内容到剪贴板
- [root@localhost advanced]# ./init
- Yii Application Initialization Tool v1.0
- Which environment do you want the application to be initialized in?
- [0] Development
- [1] Production
- Your choice [0-1, or "q" to quit] 0
- Initialize the application under 'Development' environment? [yes|no] yes
- Start initialization ...
- generate backend/config/main-local.php
- generate backend/config/params-local.php
- generate backend/web/index-test.php
- generate backend/web/index.php
- generate common/config/main-local.php
- generate common/config/params-local.php
- generate console/config/main-local.php
- generate console/config/params-local.php
- generate frontend/config/main-local.php
- generate frontend/config/params-local.php
- generate frontend/web/index-test.php
- generate frontend/web/index.php
- generate tests/codeception/config/config-local.php
- generate yii
- generate cookie validation key in backend/config/main-local.php
- generate cookie validation key in frontend/config/main-local.php
- chmod 0777 backend/runtime
- chmod 0777 backend/web/assets
- chmod 0777 frontend/runtime
- chmod 0777 frontend/web/assets
- chmod 0755 yii
- chmod 0755 tests/codeception/bin/yii
- ... initialization completed.
- [root@localhost advanced]#
配置nginx站点:
C/C++ Code复制内容到剪贴板
- [root@localhost ~]# vi /usr/local/nginx/conf/vhost/yii.conf
- #前台
- server {
- listen 80;
- server_name yii.codefarmer.wang;
- index index.php;
- root /home/site/yii/advanced/frontend/web/;
- #error_page 404 /404.html;
- include php7.conf;
- access_log off;
- }
- #后台
- server {
- listen 80;
- server_name yii_admin.codefarmer.wang;
- index index.php;
- root /home/site/yii/advanced/backend/web/;
- #error_page 404 /404.html;
- include php7.conf;
- access_log off;
- }
上一篇 返回列表
下一篇 yii2部分常见问题