位置: 编程技术 - 正文
推荐整理分享php cli配置文件问题分析(php cgi配置),希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:php cgi配置,php配置文件在哪,php配置详解,php配置文件的名字是,php配置详解,php配置文件详解,php.ini配置文件,php.ini配置文件,内容如对您有帮助,希望把文章链接给更多的朋友!
引言
今天在教别人使用protobuf的时候,无意中发现了一个php cli模式下的诡异问题,费了老半天的找到解决方法了,这里拿出来分享下。
问题描述
我们这边最先引入了protobuf协议,使用的是allegro/php-protobuf这个扩展安装的。这几天其他同事也要用到这个,于是我将protobuf生成php类库文件的部分放到了一个公共的位置/data/php_proto/文件夹下,里面有这些内容,
drwsrwxr-x 2 yanruitao users 月 : Dmp-rwxrwxr-x 1 yanruitao users 月 : dmp.protodrwsrwxr-x 2 yanruitao users 月 : ProtobufCompiler-rwxrwxr-x 1 yanruitao users 3月 9 protoc-php.php
后面两个是必须的,生成pb协议实现类库文件时会用到,前面两个是一个简单的例子,使用也很简单,就像下面这样。
php protoc-php.php -n --psr dmp.proto //-n是使用命名空间,--psr是使用psr-4标准等同事用的时候发现会报错,
PHP Warning: file_put_contents(pb_proto_dmp.php): failed to open stream: Permission denied in /data/php_proto/ProtobufCompiler/ProtobufParser.php on line
同事问我的时候我直接说,加上sudo就可以了,结果加上sudo问题更严重了,本来装好的扩展程序加载不成功,经过一番排查发下有下面这么一个问题:
$yanruitao: php -i | grep 'php.ini'$yanruitao: sudo php -i | grep 'php.ini'
两种用户加载的不是同一个配置文件,普通用户加载的是/usr/local/php/lib/php.ini,而root用户加载的是/etc/php.ini这个文件,我看了下这两个文件内容不一致,哈哈,好开心,赶紧把先把/etc/php.ini备份,/usr/local/php/lib/php.ini复制到/etc/php.ini,复制完了之后,我再使用的时候吓我一跳,报了一大堆错误:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-/web_stub_cntl.so' - /usr/local/php/lib/php/extensions/no-debug-non-zts-/web_stub_cntl.so: undefined symbol: zend_new_interned_string in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-/web_stub_cntl.so' - /usr/local/php/lib/php/extensions/no-debug-non-zts-/web_stub_cntl.so: undefined symbol: zend_new_interned_string in Unknown on line 0PHP Warning: PHP Startup: test: Unable to initialize moduleModule compiled with module API=PHP compiled with module API=These options need to match in Unknown on line 0
Warning: PHP Startup: test: Unable to initialize moduleModule compiled with module API=PHP compiled with module API=These options need to match in Unknown on line 0PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-/protobuf.so' - /usr/local/php/lib/php/extensions/no-debug-non-zts-/protobuf.so: undefined symbol: zend_new_interned_string in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-/protobuf.so' - /usr/local/php/lib/php/extensions/no-debug-non-zts-/protobuf.so: undefined symbol: zend_new_interned_string in Unknown on line 0PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-/imagick.so' - /usr/local/php/lib/php/extensions/no-debug-non-zts-/imagick.so: undefined symbol: zend_new_interned_string in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-/imagick.so' - /usr/local/php/lib/php/extensions/no-debug-non-zts-/imagick.so: undefined symbol: zend_new_interned_string in Unknown on line 0PHP Warning: PHP Startup: Unable to load dynamic library '/data/boss/phpredis-develop/modules/redis.so' - /data/boss/phpredis-develop/modules/redis.so: undefined symbol: zend_new_interned_string in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library '/data/boss/phpredis-develop/modules/redis.so' - /data/boss/phpredis-develop/modules/redis.so: undefined symbol: zend_new_interned_string in Unknown on line 0PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-/curl.so' - /usr/local/php/lib/php/extensions/no-debug-non-zts-/curl.so: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-/curl.so' - /usr/local/php/lib/php/extensions/no-debug-non-zts-/curl.so: cannot open shared object file: No such file or directory in Unknown on line 0PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-/fileinfo.so' - /usr/local/php/lib/php/extensions/no-debug-non-zts-/fileinfo.so: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-/fileinfo.so' - /usr/local/php/lib/php/extensions/no-debug-non-zts-/fileinfo.so: cannot open shared object file: No such file or directory in Unknown on line 0PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-/gd.so' - /usr/local/php/lib/php/extensions/no-debug-non-zts-/gd.so: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-/gd.so' - /usr/local/php/lib/php/extensions/no-debug-non-zts-/gd.so: cannot open shared object file: No such file or directory in Unknown on line 0PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-/json.so' - /usr/local/php/lib/php/extensions/no-debug-non-zts-/json.so: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-/json.so' - /usr/local/php/lib/php/extensions/no-debug-non-zts-/json.so: cannot open shared object file: No such file or directory in Unknown on line 0PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-/phar.so' - /usr/local/php/lib/php/extensions/no-debug-non-zts-/phar.so: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-/phar.so' - /usr/local/php/lib/php/extensions/no-debug-non-zts-/phar.so: cannot open shared object file: No such file or directory in Unknown on line 0PHP Warning: PHP Startup: Unable to load dynamic library '/data/boss/phpredis-develop/modules/redis.so' - /data/boss/phpredis-develop/modules/redis.so: undefined symbol: zend_new_interned_string in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library '/data/boss/phpredis-develop/modules/redis.so' - /data/boss/phpredis-develop/modules/redis.so: undefined symbol: zend_new_interned_string in Unknown on line 0PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-/zip.so' - /usr/local/php/lib/php/extensions/no-debug-non-zts-/zip.so: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-/zip.so' - /usr/local/php/lib/php/extensions/no-debug-non-zts-/zip.so: cannot open shared object file: No such file or directory in Unknown on line 0protoc-php.php requires protobuf extension installed to run
这让我摸不着头脑了。
时间过去了好久,没有发现任何突破,却发现了一个备用的解决这个问题的方案,修改/data/php_proto/文件夹权限为,其他普通用户就可以直接使用了,不用加sudo(这个是我的错,忘记修改文件夹权限了,这也让我发现了这个诡异的问题)
chmod -R /data/php_proto看了报的这些错误,大部分都是扩展的问题,有的是扩展加载不成功,有的是扩展不存在,我就纳闷了,为什么普通用户可以,root用户就不可以。
看到root用户php -i的时候,配置文件的地方跟非root用户有不一致的地方:
//非root
Scan this dir for additional .ini files => (none)Additional .ini files parsed => (none)
//rootScan this dir for additional .ini files => /etc/php.dAdditional .ini files parsed => /etc/php.d/curl.ini,......命名加载的是一样的配置文件怎么加载之后的内容就不一样呢?搜了半天,知道了报的错里面有部分是跟这个有关系的,但是这个在哪里修改搜了老久也没有搜到。
忽然想到root用户和非root用户使用的php可执行文件是不一致的
root => /usr/bin/php非root => /usr/local/bin/php
尝试着对这两个文件使用了php -v,结果下了我一跳,root用户的版本是5.3.3,非root用户是5.4.6,呵呵,我就呵呵了,谁部署的环境~,坑人啊。
尝试着将原有/usr/bin/php备份后,复制/usr/local/bin/php过来覆盖掉,在使用php -v发现版本一致了,也不报错了,再次去执行php protoc-php.php -n --psr dmp.proto,发现all is well,至此问题解决。
纠结了半天,结果就是版本的问题。
PHP面试题之文件目录操作 这道题其实并不难,考点主要在函数substr()strrchr()array_pop()strrpos()strpos()strrev()explode()pathinfo()。废话不多说了,直接给大家贴代码了。获取文件后缀,遍历
PHP经典面试题之设计模式(经常遇到) 设计模式在面试过程中经常会提到,有时候还会让我们举例说明各种设计模式的应用场景。使用设计模式可以减轻我们的工作量,优化我们的代码。设
php示例详解Constructor Prototype Pattern 原型模式 原型模式中主要角色抽象原型(Prototype)角色:声明一个克隆自己的接口具体原型(ConcretePrototype)角色:实现一个克隆自己的操作当一个类大部分都是相同
标签: php cgi配置
本文链接地址:https://www.jiuchutong.com/biancheng/275996.html 转载请保留说明!友情链接: 武汉网站建设