Phpcli configuration file problem analysis _ php instance

Source: Internet
Author: User
Tags php cli zts
This article mainly introduces the analysis of phpcli configuration file problems. For more information, see Introduction

Today, when I was teaching others to use protobuf, I accidentally found a strange problem in the php cli mode. I spent a long time finding a solution. I 'd like to share it here.

Problem description

We first introduced the protobuf protocol, which was installed using the extension allegro/php-protobuf. This is also used by other colleagues in the past few days, so I put the part of the php class library file generated by protobuf to a public location/data/php_proto/folder, which contains this content,

Drwsrwxr-x 2 yanruitao users 4096 October 14 17:05 Dmp
-Rwxrwxr-x 1 yanruitao users 472 17:59 dmp. proto
Drwsrwxr-x 2 yanruitao users 4096 17:54 ProtobufCompiler
-Rwxrwxr-x 1 yanruitao users 2969 March 9 protoc-php.php

The following two are mandatory and will be used to generate pb protocol implementation class library files. The first two are a simple example, which is also very simple to use, as shown below.

Php protoc-php.php-n -- his dmp. proto //-n is using namespace, -- his is using psr-4 standards and other colleagues' use will report an error,

PHP Warning: file_put_contents (pb_proto_dmp.php): failed to open stream: Permission denied in/data/php_proto/ProtobufCompiler/ProtobufParser. php on line 309

When my colleague asked me, I directly said that we can add sudo, and The sudo problem is more serious. The originally installed extension cannot be loaded, after some troubleshooting, the following problem occurs:

$ Yanruitao: php-I | grep 'php. ini'
$ Yanruitao: sudo php-I | grep 'php. ini'

The two types of user load are not the same configuration file. Common users load/usr/local/php/lib/php. ini, while the root user loads/etc/php. ini file. I have read the inconsistency between the two files. Haha, I'm so happy. Hurry up and put/etc/php first. ini backup,/usr/local/php/lib/php. copy ini to/etc/php. ini. After I copied it, I was shocked when I used it again and reported a lot of errors:

PHP Warning: PHP Startup: unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/web_stub_cntl.so'-/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/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-20100525/web_stub_cntl.so'-/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/web_stub_cntl.so: undefined symbol: zend_new_interned_string in Unknown on line 0
PHP Warning: PHP Startup: test: Unable to initialize module
Module compiled with module API = 20100525
PHP compiled with module API = 20090626
These options need to match
In Unknown on line 0

Warning: PHP Startup: test: Unable to initialize module
Module compiled with module API = 20100525
PHP compiled with module API = 20090626
These options need to match
In Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/protobuf. so '-/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/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-20100525/protobuf. so '-/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/protobuf. so: undefined symbol: zend_new_interned_string in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/imagick. so '-/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/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-20100525/imagick. so '-/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/imagick. so: undefined symbol: zend_new_interned_string in Unknown on line 0
PHP 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 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/curl. so '-/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/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-20100525/curl. so '-/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/curl. so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/fileinfo. so '-/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/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-20100525/fileinfo. so '-/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/fileinfo. so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/gd. so '-/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/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-20100525/gd. so '-/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/gd. so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/json. so '-/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/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-20100525/json. so '-/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/json. so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/phar. so '-/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/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-20100525/phar. so '-/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/phar. so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP 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 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/zip. so '-/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/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-20100525/zip. so '-/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/zip. so: cannot open shared object file: No such file or directory in Unknown on line 0
Protoc-php.php (requires protobuf extension installed to run)

This leaves me confused.

After a long time, no breakthrough was found, but a standby solution was found to solve this problem. The permission to modify/data/php_proto/folder is 0775, other common users can use it directly without adding sudo (this is my fault. I forgot to modify the folder permission, which also caused me to find this strange problem)

Chmod-R 0775/data/php_proto
After reading these errors, most of them are expansion problems. Some of them cannot be loaded successfully, and some others do not exist. I am wondering why ordinary users can, but root users cannot.

When you see the root user php-I, the configuration file is different from the non-root User:

// Non-root

Scan this dir for additional. ini files => (none)
Additional. ini files parsed => (none)

// Root
Scan this dir for additional. ini files =>/etc/php. d
Additional. ini files parsed =>/etc/php. d/curl. ini,
......
Naming is loaded with the same configuration file. How can I load different content?
After searching for half a day, I learned that some of the errors I reported were related to this, but I still did not find any changes I found.

The php executable files used by root users and non-root users are inconsistent.

Root =>/usr/bin/php
Non-root =>/usr/local/bin/php

I tried to use php-v for these two files. As a result, I got a hop. the root user version is 5.3.3 and the non-root user is 5.4.6, WHO deployed the environment ~, Ah.

After trying to back up the original/usr/bin/php file, copy/usr/local/bin/php to overwrite it. When using php-v, we found that the version was consistent, also do not report the error, again to execute php protoc-php.php-n -- psr dmp. proto, found all is well, this problem is resolved.

After a long struggle, the result is the version issue.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.