用yii2以来,安装composer老是不成功,所以一直在windows下的php里,用直接解压的方法运行yii2。
后来越来越多的场合,需要用composer,终于下决心,要在Linux下搞掂它!
-----------------------------------------
一、安装composer
# curl -sS https://getcomposer.org/installer | php
这个老是下载不成功。干脆手动下载 composer.pchar,再扔进服务器,然后:
# mv composer.phar /usr/local/bin/composer
# chmod +x user/local/bin/composer
由于composer强烈不建议在root下运行。我建立了一个新用户
# adduser yii2
设置国外镜像(否则会被墙)
$ composer config -g repo.packagist composer https://packagist.phpcomposer.com
然后安装一个什么插件?
$ composer global require "fxp/composer-asset-plugin:1.0.0-beta3"
这里又出错了。一堆错误信息。我去掉后面的版本号
$ composer global require "fxp/composer-asset-plugin"
出现提示:
- Installing fxp/composer-asset-plugin (v1.2.2) ...
这样就好了。
二、安装yii2
$ composer create-project --prefer-dist yiisoft/yii2-app-basic basic
- yiisoft/yii2 2.0.9 requires bower-asset/jquery 2.2.*@stable | 2.1.*@stable | 1.11.*@stable | 1.12.*@stable -> no matching package found.
看了 http://blog.csdn.net/wsliangjian/article/details/46738739
$ cd basic
$ composer update
一些操作后,(下载了N多文件),提示输入token,
查到这个 https://getyii.com/topic/default/view/32 解决使用Composer的时候提示输入Token
生成了 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
以下下载了一大堆东西。
再次测试生成的web网站,出现:
Failed to create directory "/www/default/basic/runtime/logs": mkdir(): Permission denied
$ chmod g+w -R basic
(此处我将yii2与www设为同组,所以可以设置组内可写)
再进web页面,出现:
yiiwebRequest::cookieValidationKey must be configured with a secret key.
此处,修改 config/web.php,在components下,request下,cookieValidationKey后面,随机输入一堆字符,保存。
再试,通过!
===============================================
一鼓作气,继续解决了windows7下安装!
C>composer config -g repo.packagist composer https://packagist.phpcomposer.com
C>composer config -g -- disable-tls true
修改php.ini,去掉 extension=php_openssl.dll 前的 ;
C>composer global require "fxp/composer-asset-plugin"
Changed current directory to C:/Users/Administrator/AppData/Roaming/Composer
You are running Composer with SSL/TLS protection disabled.
Using version ^1.2 for fxp/composer-asset-plugin
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing fxp/composer-asset-plugin (v1.2.2)
Downloading: 100%
Writing lock file
Generating autoload files
C>composer update
C>composer create-project --prefer-dist yiisoft/yii2-app-basic mybasic
OK!!!
----------------------------------------
以上参考了:
http://www.cnblogs.com/yangtoude/p/5323561.html composer安装yii2问题总结
http://www.yiichina.com/topic/6423 composer安装Yii2,写给总是安装不成功的朋友!