YII 测试环境搭建

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)'

  此时可以参照如下方案来解决:

    1. 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
    2. Fire up Terminal and issue sudo Nautilus
      This starts your Files manager with super user privileges
    3. From Nautilus navigate to where your mysql.sock file is located
    4. Right click on the file and select Make Link
    5. Rename the Link File to mysqld.sock then Right click on the file and Cut it
    6. Go to /var/run and create a folder called mysqld and enter it
    7. Now right click and Paste the Link File
    8. Voila! You will now have a mysqld.sock file at /var/run/mysqld/mysqld.sock :)
  1. 以上都是临时解决方案,因为重新启动后所建立的文件和文件夹就都消失了,最终极的解决方案是打开: /opt/lampp/etc/my.cn, 修改其中的server的socket地址即可!!!!!!!
  2. 第九步仍然不是最好的办法,因为改动了/opt/lampp/etc/my.cn里边关于socket的设置以后,原来依赖它的程序可能无法正常运行,最好的解决方案是从原来的/opt/lampp/var/mysql/mysql.sock建立一个软链接到需要的地方,比如/var/run/mysqld/mysqld.sock就可以了.  具体方法是在建立一个脚本在/etc/init/mysqld.conf
  3. 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命令修改回来!

  

转载于:https://www.cnblogs.com/wlemory/p/4616447.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值