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主题或者插件的安装方法,一共有三种方式: 第一种是直接在网站后 ...
随机推荐
- Prism6下的MEF:第一个Hello World
最近看书比较多,正好对过去几年的软件开发做个总结.写这个的初衷只是为了简单的做一些记录. 前言 复杂的应用程序总是面临很多的页面之间的数据交互,怎样创建松耦合的程序一直是多数工程师所思考的问题.诸如依 ...
- 0422数学口袋精灵bug发现
团队成员的博客园地址: 蔡彩虹:http://home.cnblogs.com/u/caicaihong/ 曾治业:http://www.cnblogs.com/zzy999/ 蓝叶:http://w ...
- 动态语句SQL语句写法
/*************************************************************************************************** ...
- Nginx和Apache区别
Nginx VS Apache 相同点: 1.都是HTTP服务器软件 2.功能上都采用模块化结构设计 3.都支持通用的语言接口,如PHP.Perl.Python等 4.支持正向.反向代理.虚拟主机. ...
- 微信 小程序布局 swiper 页面
JS // pages/classify/swiper.js Page({ /** * 页面的初始数据 */ data: { current:0 }, titleBtn:function(e){ ...
- 用SQL查询方式显示GROUP BY中的TOP解决方法[转]
用SQL查询方式显示GROUP BY中的TOP怎样用一个SQL语句来显示 分组后每个组的前几位 比如把一个学校所有学生的成绩按班级分组,再显示每个班级前五名的信息. 班级 学生 成绩 一班 ...
- ACdream1092
题意是给出某个地鼠的出现位置以及出现时间,人有一个移动速度,求此人最多可以打多少个地鼠? 我们根据时间把所有的地鼠排序,如果两个地鼠之间的距离不超过时间只差与速度的乘积,那说明打完上一只地鼠还可以打到 ...
- hdu6438 Buy and Resell
多少年不写题了... (我把每一天看作是一个商品,第i天是第i个商品) 一开始看了半天看出来一个性质:买的所有商品中最贵的不会比卖的所有商品中最便宜的贵,然后似乎没有什么用处.... 所以最后还是看题 ...
- 一条慢SQL引发的血案
直接切入正题吧: 通常来说,我们看到的慢查询一般还不致于导致挂站,顶多就是应用响应变慢不过这个恰好今天被我撞见了,一个慢查询把整个网站搞挂了先看看这个SQL张撒样子: # Query_time: 70 ...
- P3455 [POI2007]ZAP-Queries
题目描述 Byteasar the Cryptographer works on breaking the code of BSA (Byteotian Security Agency). He ha ...