phpunit安装出错的原因及解决办法
官方指引
很遗憾, phpunit还没有在ArchLinux的仓库里。
所以使用下载安装的方式。按照官方的指引:
wget https://phar.phpunit.de/phpunit.phar
chmod +x phpunit.phar
sudo mv phpunit.phar /usr/local/bin/phpunit
phpunit --version
结果得到下面的错误:
PHP Warning: realpath(): open_basedir restriction in effect. File(/usr/local/bin/phpunit) is not within the allowed path(s): (/srv/http/:/home/:/tmp/:/usr/share/pear/) in /usr/local/bin/phpunit on line 3
PHP Fatal error: Class 'Phar' not found in /usr/local/bin/phpunit on line 714
启用phar扩展
先解决Fatal error: Class 'Phar' not found
。
ls /usr/lib/php/modules
发现有 phar.so,说明Phar的扩展已经安装,那么是不是该扩展没有Enable呢?
打开 /etc/php/php.ini
搜索 phar
,果然发现 extension=phar.so
被注释掉了。去掉该行前面的 ;
,保存php.ini,再次运行 phpunit --version
。
PHP Warning: realpath(): open_basedir restriction in effect. File(/usr/local/bin/phpunit) is not within the allowed path(s): (/srv/http/:/home/:/tmp/:/usr/share/pear/) in /usr/local/bin/phpunit on line 3
PHP Warning: Phar::mapPhar(): open_basedir restriction in effect. File(/usr/local/bin/phpunit) is not within the allowed path(s): (/srv/http/:/home/:/tmp/:/usr/share/pear/) in /usr/local/bin/phpunit on line 714
Fatal error
解决了,但警告还在,而且phpunit没有正常运行。
php对文件访问的保护机制
google之,发现这里有解释: http://www.templatemonster.com/help/open_basedir-restriction-in-effect-filex-is-not-within-the-allowed-paths-y.html
PHP open_basedir protection tweak is a Safe Mode security measure that prevents users from opening files or scripts located outside of their home directory with PHP, unless the folder has specifically excluded. PHP open_basedir setting if enabled, will ensure that all file operations to be limited to files under certain directory, and thus prevent php scripts for a particular user from accessing files in unauthorized user’s account. When a script tries to open a file with, for example, fopen() or gzopen(), the location of the file is checked. When the file is outside the specified or permissible directory-tree, PHP will refuse to open it and the following errors may occur: ...
意思是说:php.ini中的open_basedir
是php为保证安全进行文件访问的设置。如果该选项被赋值,所有的文件操作将限定在特定的目录里,这样可以防止某个用户使用php脚本读取未授权的内容。当你想通过fopen
或gzopen
打开一个文件时,如果该文件的位置不再被允许的目录下面,就会出现上述的警告信息。
从警告信息发现可以访问的目录包括 /srv/http/:/home/:/tmp/:/usr/share/pear/
,刚好 ~/bin
即在PATH变量中,也属于可以被php脚本读取的目录,于是
mv /usr/local/bin/phpunit ~/bin
再运行phpunit --version
,得到正确结果:
PHPUnit 4.5.0 by Sebastian Bergmann and contributors.
phpunit安装成功!
phpunit安装出错的原因及解决办法的更多相关文章
- jquery.min.map 404 (Not Found)出错的原因及解决办法
Chrome 更新后出现了 jquery.min.map 404 (Not Found) 的信息 这个到底是什么东西?查询了一下,得到了以下资料 JQuery 官方解释 摘录一下內容 从 jQuer ...
- 整理 node-sass 安装失败的原因及解决办法
npm install 时偶尔遇到报错:没有安装python或node-sass 安装失败的问题,百度之后发现是被墙了,但根据百度的方法换了淘宝镜像和用了vpn都安装失败,最后发现原来是因为没有卸载之 ...
- 整理Mac系统 node-sass 安装失败的原因及解决办法
转载与:https://segmentfault.com/a/1190000010984731 声明:本文非原创,如有侵权请留言或发邮件告知,作者会立即停止侵权并删除本文.发布此文章主要是希望跟作者遇 ...
- javascirpt的json.stringify()方法在IE浏览器兼容性模式下出错的原因与解决办法
今天开机混底薪的时候遇到一个JSON.stringify()在IE浏览器兼容模式下的问题. 问题描述 一个弹窗选择的功能原来好好的,突然就不行了. 想要调试调试不了,报错信息也看不到(一开F12这破I ...
- node-sass 安装失败的原因及解决办法
出处:https://segmentfault.com/a/1190000010984731 windows 上用 yarn add node-sass --dev 也可以安装上.
- Visual Studio build tools 安装出错的一种解决办法
一般是安装包丢失或损坏,那么我么可以用离线下载的方式来先行下载. 用 -h 看下帮助 主要是Layout参数. 下载完,到下载目录安装吧.
- python基础===Windows环境下使用pip install 安装出错"Cannot unpack file"解决办法
不知道为什么,加了豆瓣镜像源还是不行 这个命令可以解决! pip install -i http://pypi.douban.com/simple/ --trusted-host pypi.douba ...
- (转)整理 node-sass 安装失败的原因及解决办法
转载地址:https://segmentfault.com/a/1190000010984731
- zblog上传安装主题插件不成功的原因和解决办法
最近有不少zblog用户反映在后台上传安装主题或者插件的时候出现了问题.本文就来尝试说明下这类问题的原因和解决办法. 首先来说说zblog主题或者插件的安装方法,一共有三种方式: 第一种是直接在网站后 ...
随机推荐
- IE8+SpringMVC文件上传防止JSON下载
今天在IE8测试文件上传的时候发现总是提示下载,原因是上传接口返回的是json,通过以下修改就可以保证返回是json并且不会出现下载的情况: @RequestMapping(value = " ...
- scrapy-下载器中间件
from faker import Faker class MySpiderMiddleware(object): def __init__(self): self.fake = Faker() de ...
- mongo学习1 (转)
关于mongodb的好处,优点之类的这里就不说了,唯一要讲的一点就是mongodb中有三元素:数据库,集合,文档,其中“集合” 就是对应关系数据库中的“表”,“文档”对应“行”. 一: 下载 上Mon ...
- Linux中Apache+Tomcat+JK实现负载均衡和群集的完整过程
人原创,一个字一个字地码的,尊重版权,转载请注明出处! http://blog.csdn.net/chaijunkun/article/details/6987443 最近在开发的项目需要承受很高的并 ...
- 通过ClientDataSet复制表的结构及数据
1. 需要2个ClientDataSet组件: 2. clientDataSet1连接目标表,clientDataSet2连接源表,如果无法直接连接,使用DataSetProvider进行桥接: ...
- 【Python】使用python操作mysql数据库
这是我之前使用mysql时用到的一些库及开发的工具,这里记录下,也方便我查阅. python版本: 2.7.13 mysql版本: 5.5.36 几个python库 1.mysql-connector ...
- 【Java并发编程】之十二:线程间通信中notifyAll造成的早期通知问题
如果线程在等待时接到通知,但线程等待的条件还不满足,此时,线程接到的就是早期通知,如果条件满足的时间很短,但很快又改变了,而变得不再满足,这时也将发生早期通知.这种现象听起来很奇怪,下面通过一个示例程 ...
- js浏览器缩放提示
data() { return { instance: null, isZoomOpen: false }; }, mounted() { const that = this; this.isZoom ...
- 【BZOJ2733】永无乡(线段树,并查集)
[BZOJ2733]永无乡(线段树,并查集) 题面 BZOJ 题解 线段树合并 线段树合并是一个很有趣的姿势 前置技能:动态开点线段树 具体实现:每次合并两棵线段树的时候,假设叫做\(t1,t2\), ...
- Alpha 冲刺 —— 十分之八
队名 火箭少男100 组长博客 林燊大哥 作业博客 Alpha 冲鸭鸭鸭鸭鸭鸭鸭鸭! 成员冲刺阶段情况 林燊(组长) 过去两天完成了哪些任务 协调各成员之间的工作 多次测试软件运行 学习OPENMP ...