1:首先按照官方指导安装所需组件
For the local installation use following commands:
composer require "codeception/codeception=2.0.*"
composer require "codeception/specify=*"
composer require "codeception/verify=*"
For the global installation you will need to use global
directive:
composer global require "codeception/codeception=2.0.*"
composer global require "codeception/specify=*"
composer global require "codeception/verify=*"
2:安装完后可能会提示缺少数据库的驱动:
可以按照命令 sudo apt-get install php5-mysql 来安装缺少的PHP 组件
3:安装号如上后可能会遇到错误提示如下:
error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
此时可以参照如下方案来解决:
- First, you have to locate(in Terminal with "sudo find / -type s") where your
mysql.sock
file is located. In my case it was in/opt/lampp/var/mysql/mysql.sock
- Fire up Terminal and issue
sudo Nautilus
This starts your Files manager with super user privileges - From Nautilus navigate to where your
mysql.sock
file is located - Right click on the file and select Make Link
- Rename the Link File to
mysqld.sock
then Right click on the file and Cut it - Go to
/var/run
and create a folder calledmysqld
and enter it - Now right click and Paste the Link File
- Voila! You will now have a
mysqld.sock
file at/var/run/mysqld/mysqld.sock
:) - 以上都是临时解决方案,因为重新启动后所建立的文件和文件夹就都消失了,最终极的解决方案是打开: /opt/lampp/etc/my.cn, 修改其中的server的socket地址即可!!!!!!!
- 第九步仍然不是最好的办法,因为改动了/opt/lampp/etc/my.cn里边关于socket的设置以后,原来依赖它的程序可能无法正常运行,最好的解决方案是从原来的
/opt/lampp/var/mysql/mysql.sock
建立一个软链接到需要的地方,比如/var/run/mysqld/mysqld.sock
就可以了. 具体方法是在建立一个脚本在/etc/init/mysqld.conf -
start on runlevel [2345] stop on runlevel [!2345] expect daemon pre-start script mkdir -p -m0755 /var/run/mysqld chown mysql:mysql /var/run/mysqld ln -s /opt/lampp/var/mysql/mysql.sock /var/run/mysqld/mysqld.sock end script exec /etc/init.d/mysql start pre-stop exec /etc/init.d/mysql stop
4:扫平所有问题后,如在测试中有访问数据库,需要配置tests/config/config,配置方法参照config/db
5:在安装过程中注意一个问题,测试环境用的是PHP CLI和APACHE用的不是同一个php
php -i | grep 'Configuration File'来查看cli的php版本
编辑一个文件用浏览器打开 <?php phpinfo();?> 来查看阿帕奇的php版本
如果不是第一次安装但是出了如上错误,可能还有问题是,文件的权限不对!
比如以ROOT身份操作了/opt/lampp/var/mysql下的文件以后,造成文件权限不对,也会造成这个问题,如出现权限问题,可以使用chmod 和 chown命令修改回来!