');}

yii framework(易框架)搭建

Author Avatar
稻草人 2月 15, 2017

近期公司有项目需要易框架来写php,遂先简单写个该框架的搭建教程.

安装xampp

https://www.apachefriends.org/download.html
下载对应php版本的xampp.
win10的C盘权限管控略严,所以建议安装在其它盘的根目录(如D:\xampp),安装过程略过.

安装易框架

http://www.yiiframework.com/download/
Ctrl+F搜索Install from an Archive File
点击第二个Yii 2 with advanced application template进行下载
下载完成后以管理员权限启动winrar对下好的tgz解压,解压到D:\xampp\htdocs
目录结构见下图
directory.jpg

将php加入环境变量

  1. D:\xampp\php\

初始化

返回D:\xampp\目录,按住shift鼠标定位到htdocs右键,再按w,将出现如下窗口
cmd.jpg
输入init.bat,并按下图输入指令
init.jpg

修改apache配置文件

打开D:\xampp\apache\conf\extra\httpd-vhosts.conf,末尾处添加如下一段并保存

  1. <VirtualHost *:80>
  2. ServerName frontend.dev
  3. DocumentRoot "D:/xampp/htdocs/frontend/web/"
  4. <Directory "D:/xampp/htdocs/frontend/web/">
  5. # use mod_rewrite for pretty URL support
  6. RewriteEngine on
  7. # If a directory or a file exists, use the request directly
  8. RewriteCond %{REQUEST_FILENAME} !-f
  9. RewriteCond %{REQUEST_FILENAME} !-d
  10. # Otherwise forward the request to index.php
  11. RewriteRule . index.php
  12. # use index.php as index file
  13. DirectoryIndex index.php
  14. # ...other settings...
  15. # Apache 2.4
  16. Require all granted
  17. ## Apache 2.2
  18. # Order allow,deny
  19. # Allow from all
  20. </Directory>
  21. </VirtualHost>
  22. <VirtualHost *:80>
  23. ServerName backend.dev
  24. DocumentRoot "D:/xampp/htdocs/backend/web/"
  25. <Directory "D:/xampp/htdocs/backend/web/">
  26. # use mod_rewrite for pretty URL support
  27. RewriteEngine on
  28. # If a directory or a file exists, use the request directly
  29. RewriteCond %{REQUEST_FILENAME} !-f
  30. RewriteCond %{REQUEST_FILENAME} !-d
  31. # Otherwise forward the request to index.php
  32. RewriteRule . index.php
  33. # use index.php as index file
  34. DirectoryIndex index.php
  35. # ...other settings...
  36. # Apache 2.4
  37. Require all granted
  38. ## Apache 2.2
  39. # Order allow,deny
  40. # Allow from all
  41. </Directory>
  42. </VirtualHost>

添加hosts

打开C:\Windows\System32\drivers\etc,将下列两行添加至末尾并保存

  1. 127.0.0.1 frontend.dev
  2. 127.0.0.1 backend.dev

启动apache

打开xampp control panel,点击Apache后的Start,如下图所示,即表示启动成功
apache.jpg
如出现错误请根据提示进行操作,再重启apache(如skype会占用80,443端口,在skype中设置即可)

验证yii framework是否安装成功

http://frontend.dev/
frontend.jpg

http://backend.dev
backend.jpg

至此,易框架搭建成功!!!