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主题或者插件的安装方法,一共有三种方式: 第一种是直接在网站后 ...
随机推荐
- 记:ASP.NET Core开发时部署到IIS上出现HTTP Error 502.5 - Process Failure的解决方案
HTTP Error 502.5 - Process Failure Common causes of this issue: The application process failed to st ...
- Apache优化之多路处理模块理解
前言: 当项目被多人访问时导致访问数度变慢,查了许多资料,了解到Apache的核心模块——MPM(多路处理访问模块).在此对MPM的一些知识点进行整理. MPM_WINNT模块 windows系统使用 ...
- cxGrid 单元格回车移到下一行,当移到最后一个单元格时回车新增一行【转】
1 在TcxGridDBTableView中,设定属性 NewItemRow.Visible = True 2 在cxgrid中输入数据怎样回车换行 在TcxGridDBTableView中 将属 ...
- [转帖]awk 入门
awk其实不仅仅是工具软件,还是一种编程语言.不过,本文只介绍它的命令行用法,对于大多数场合,应该足够用了. http://www.ruanyifeng.com/blog/2018/11/awk.ht ...
- ajax极简教程
一.什么是ajax ajax即异步JavaScript和XML,它是一种用于创建快速动态网页的技术.作用是通过在后台与服务器进行少量数据交换,使网页实现异步更新.这意味着可以在不重新加载整个网页的情况 ...
- ASP.NET MVC中在 @RenderBody() 或者 @Html.Partial()中需要使用引入外部js,css
今天想在后台封装一下bootstraptree这个插件,引入jquery.js bootstrap.js bootstrap.css bootstrap-tree.js后,我在页面查看脚本错误就连最简 ...
- LeetCode 717. 1-bit and 2-bit Characters
We have two special characters. The first character can be represented by one bit 0. The second char ...
- Java之IO流(字节流,字符流)
IO流和Properties IO流 IO流是指计算机与外部世界或者一个程序与计算机的其余部分的之间的接口.它对于任何计算机系统都非常关键, 因而所有 I/O 的主体实际上是内置在操作系统中的.单独的 ...
- 利用Array Prototype的方法来实现对dom集合的筛选、indexOf、map等功能
<!DOCTYPE html><html> <head> <title>TODO supply a title</title> <me ...
- Java入门:基础算法之产生随机数
本程序演示使用Random类的呢想tInt()方法产生随机数. /* Program: 随机数发生器 * Written by: 理工云课堂 * Input: None * Output: 0 到20 ...