警告:模块“curl”已经在第0行的Unknown中加载(从custom.php.ini文件中修复)

在网站上做了一些研究之后,出现这个错误的原因是php.ini文件很可能包含了一个引用,当它已经被编译到PHP中的时候加载扩展。

也就是说,我正在使用Docker和Docker-Compose。 我find了一种方法来保持默认的php.ini文件,任何更改将被我的custom.php.ini文件覆盖。

这是因为这个…(这只是我的docker-compose.yml文件中的一小段代码)

web: build: ./ depends_on: - dblive - dbdev volumes: - ./web:/var/www - ./config/custom.php.ini:/etc/php5/apache2/conf.d/custom.php.ini 

注意到我有我自己的custom.php.ini文件,它映射到PHP查找额外的php.ini文件的目录。 这完美的作品。

目前在这个custom.php.ini文件中,我有这个。

 asp_tags = Off display_errors = On display_startup_errors = On 

我现在正在收到一个错误…

 PHP Warning: Module 'curl' already loaded in Unknown on line 0 Warning: Module 'curl' already loaded in Unknown on line 0 

如何编辑这个外部php.ini文件来禁用加载扩展?

可能的替代scheme

由于我运行的方式,我也有一个Docker在开始修改初始的php.ini文件时运行的运行脚本。

看起来像这样

 #!/bin/bash set -e #Edits to the default php.ini file go here PHP_ERROR_REPORTING=${PHP_ERROR_REPORTING:-"E_ALL & ~E_DEPRECATED & ~E_NOTICE"} sed -ri 's/^display_errors\s*=\s*Off/display_errors = On/g' /etc/php5/apache2/php.ini sed -ri 's/^display_errors\s*=\s*Off/display_errors = On/g' /etc/php5/cli/php.ini sed -ri "s/^error_reporting\s*=.*$//g" /etc/php5/apache2/php.ini sed -ri "s/^error_reporting\s*=.*$//g" /etc/php5/cli/php.ini echo "error_reporting = $PHP_ERROR_REPORTING" >> /etc/php5/apache2/php.ini echo "error_reporting = $PHP_ERROR_REPORTING" >> /etc/php5/cli/php.ini source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND 

这允许覆盖一些默认值,但我不知道要在这里更改以禁用cURL(如果这甚至是最好的地方做)?

这个错误发生在我使用composer php时,我检查了php.ini文件,但似乎没有看到cURL加载?

php.info的结果在这里

 distribution:PSS_APP_Docker josephastrahan$ docker exec -it pssappdocker_web_1 bash -c "php -r 'phpinfo();'" PHP Warning: Module 'curl' already loaded in Unknown on line 0 Warning: Module 'curl' already loaded in Unknown on line 0 PHP Warning: phpinfo(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in Command line code on line 1 phpinfo() PHP Version => 5.5.30 System => Linux 1866210b51f6 4.9.13-moby #1 SMP Sat Mar 25 02:48:44 UTC 2017 x86_64 Build Date => Apr 13 2017 00:03:22 Configure Command => './configure' '--prefix=/usr' '--with-config-file-path=/etc/php5/apache2' '--with-config-file-scan-dir=/etc/php5/apache2/conf.d' '--disable-pdo' '--disable-json' '--enable-mbstring' '--with-apxs2' '--with-openssl' '--with-openssl-dir=/usr/local/bin' '--with-curl=/usr/local' Server API => Command Line Interface Virtual Directory Support => disabled Configuration File (php.ini) Path => /etc/php5/apache2 Loaded Configuration File => /etc/php5/apache2/php.ini Scan this dir for additional .ini files => /etc/php5/apache2/conf.d Additional .ini files parsed => /etc/php5/apache2/conf.d/05-opcache.ini, /etc/php5/apache2/conf.d/10-mysqlnd.ini, /etc/php5/apache2/conf.d/10-pdo.ini, /etc/php5/apache2/conf.d/20-curl.ini, /etc/php5/apache2/conf.d/20-gd.ini, /etc/php5/apache2/conf.d/20-json.ini, /etc/php5/apache2/conf.d/20-ldap.ini, /etc/php5/apache2/conf.d/20-mysql.ini, /etc/php5/apache2/conf.d/20-mysqli.ini, /etc/php5/apache2/conf.d/20-pdo_mysql.ini, /etc/php5/apache2/conf.d/20-pdo_pgsql.ini, /etc/php5/apache2/conf.d/20-pgsql.ini, /etc/php5/apache2/conf.d/20-readline.ini, /etc/php5/apache2/conf.d/custom.php.ini PHP API => 20121113 PHP Extension => 20121212 Zend Extension => 220121212 Zend Extension Build => API220121212,NTS PHP Extension Build => API20121212,NTS Debug Build => no Thread Safety => disabled Zend Signal Handling => disabled Zend Memory Manager => enabled Zend Multibyte Support => provided by mbstring IPv6 Support => enabled DTrace Support => disabled Registered PHP Streams => https, ftps, php, file, glob, data, http, ftp, phar Registered Stream Socket Transports => tcp, udp, unix, udg, ssl, sslv3, tls Registered Stream Filters => convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk This program makes use of the Zend Scripting Language Engine: Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies _______________________________________________________________________ Configuration Core PHP Version => 5.5.30 Directive => Local Value => Master Value allow_url_fopen => On => On allow_url_include => Off => Off always_populate_raw_post_data => Off => Off arg_separator.input => & => & arg_separator.output => & => & asp_tags => Off => Off auto_append_file => no value => no value auto_globals_jit => On => On auto_prepend_file => no value => no value browscap => no value => no value default_charset => no value => no value default_mimetype => text/html => text/html disable_classes => no value => no value disable_functions => pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, => pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, display_errors => STDOUT => STDOUT display_startup_errors => On => On doc_root => no value => no value docref_ext => no value => no value docref_root => no value => no value enable_dl => Off => Off enable_post_data_reading => On => On error_append_string => no value => no value error_log => no value => no value error_prepend_string => no value => no value error_reporting => 24567 => 24567 exit_on_timeout => Off => Off expose_php => On => On extension_dir => /usr/lib/php5/20121212 => /usr/lib/php5/20121212 file_uploads => On => On highlight.comment => <font style="color: #FF8000">#FF8000</font> => <font style="color: #FF8000">#FF8000</font> highlight.default => <font style="color: #0000BB">#0000BB</font> => <font style="color: #0000BB">#0000BB</font> highlight.html => <font style="color: #000000">#000000</font> => <font style="color: #000000">#000000</font> highlight.keyword => <font style="color: #007700">#007700</font> => <font style="color: #007700">#007700</font> highlight.string => <font style="color: #DD0000">#DD0000</font> => <font style="color: #DD0000">#DD0000</font> html_errors => Off => Off ignore_repeated_errors => Off => Off ignore_repeated_source => Off => Off ignore_user_abort => Off => Off implicit_flush => On => On include_path => .:/usr/lib/php => .:/usr/lib/php log_errors => On => On log_errors_max_len => 1024 => 1024 mail.add_x_header => On => On mail.force_extra_parameters => no value => no value mail.log => no value => no value max_execution_time => 0 => 0 max_file_uploads => 20 => 20 max_input_nesting_level => 64 => 64 max_input_time => -1 => -1 max_input_vars => 1000 => 1000 memory_limit => 128M => 128M open_basedir => no value => no value output_buffering => 0 => 0 output_handler => no value => no value post_max_size => 8M => 8M precision => 14 => 14 realpath_cache_size => 16K => 16K realpath_cache_ttl => 120 => 120 register_argc_argv => On => On report_memleaks => On => On report_zend_debug => Off => Off request_order => GP => GP sendmail_from => no value => no value sendmail_path => -t -i => -t -i serialize_precision => 17 => 17 short_open_tag => Off => Off SMTP => localhost => localhost smtp_port => 25 => 25 sql.safe_mode => Off => Off sys_temp_dir => no value => no value track_errors => Off => Off unserialize_callback_func => no value => no value upload_max_filesize => 2M => 2M upload_tmp_dir => no value => no value user_dir => no value => no value user_ini.cache_ttl => 300 => 300 user_ini.filename => .user.ini => .user.ini variables_order => GPCS => GPCS xmlrpc_error_number => 0 => 0 xmlrpc_errors => Off => Off zend.detect_unicode => On => On zend.enable_gc => On => On zend.multibyte => Off => Off zend.script_encoding => no value => no value ctype ctype functions => enabled curl cURL support => enabled cURL Information => 7.35.0 Age => 3 Features AsynchDNS => Yes CharConv => No Debug => No GSS-Negotiate => Yes IDN => Yes IPv6 => Yes krb4 => No Largefile => Yes libz => Yes NTLM => Yes NTLMWB => Yes SPNEGO => No SSL => Yes SSPI => No TLS-SRP => Yes Protocols => dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3, pop3s, rtmp, rtsp, smtp, smtps, telnet, tftp Host => x86_64-pc-linux-gnu SSL Version => OpenSSL/1.0.1f ZLib Version => 1.2.8 date date/time support => enabled "Olson" Timezone Database Version => 2015.5 Timezone Database => internal Warning: phpinfo(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in Command line code on line 1 Default timezone => UTC Directive => Local Value => Master Value date.default_latitude => 31.7667 => 31.7667 date.default_longitude => 35.2333 => 35.2333 date.sunrise_zenith => 90.583333 => 90.583333 date.sunset_zenith => 90.583333 => 90.583333 date.timezone => no value => no value dom DOM/XML => enabled DOM/XML API Version => 20031129 libxml Version => 2.9.1 HTML Support => enabled XPath Support => enabled XPointer Support => enabled Schema Support => enabled RelaxNG Support => enabled ereg Regex Library => Bundled library enabled fileinfo fileinfo support => enabled version => 1.0.5 filter Input Validation and Filtering => enabled Revision => $Id: fbeb8bbbf6cc97f568996dac46e13e48e2907326 $ Directive => Local Value => Master Value filter.default => unsafe_raw => unsafe_raw filter.default_flags => no value => no value gd GD Support => enabled GD Version => 2.1.1-dev FreeType Support => enabled FreeType Linkage => with freetype FreeType Version => 2.5.2 GIF Read Support => enabled GIF Create Support => enabled JPEG Support => enabled libJPEG Version => 8 PNG Support => enabled libPNG Version => 1.2.50 WBMP Support => enabled XPM Support => enabled libXpm Version => 30411 XBM Support => enabled WebP Support => enabled Directive => Local Value => Master Value gd.jpeg_ignore_warning => 0 => 0 hash hash support => enabled Hashing Engines => md2 md4 md5 sha1 sha224 sha256 sha384 sha512 ripemd128 ripemd160 ripemd256 ripemd320 whirlpool tiger128,3 tiger160,3 tiger192,3 tiger128,4 tiger160,4 tiger192,4 snefru snefru256 gost adler32 crc32 crc32b fnv132 fnv164 joaat haval128,3 haval160,3 haval192,3 haval224,3 haval256,3 haval128,4 haval160,4 haval192,4 haval224,4 haval256,4 haval128,5 haval160,5 haval192,5 haval224,5 haval256,5 iconv iconv support => enabled iconv implementation => glibc iconv library version => 2.19 Directive => Local Value => Master Value iconv.input_encoding => ISO-8859-1 => ISO-8859-1 iconv.internal_encoding => ISO-8859-1 => ISO-8859-1 iconv.output_encoding => ISO-8859-1 => ISO-8859-1 json json support => enabled json version => 1.3.2 JSON-C version (bundled) => 0.11 ldap LDAP Support => enabled RCS Version => $Id$ Total Links => 0/unlimited API Version => 3001 Vendor Name => OpenLDAP Vendor Version => 20431 SASL Support => Enabled Directive => Local Value => Master Value ldap.max_links => Unlimited => Unlimited libxml libXML support => active libXML Compiled Version => 2.9.1 libXML Loaded Version => 20901 libXML streams => enabled mbstring Multibyte Support => enabled Multibyte string engine => libmbfl HTTP input encoding translation => disabled libmbfl version => 1.3.2 mbstring extension makes use of "streamable kanji code filter and converter", which is distributed under the GNU Lesser General Public License version 2.1. Multibyte (japanese) regex support => enabled Multibyte regex (oniguruma) backtrack check => On Multibyte regex (oniguruma) version => 5.9.2 Directive => Local Value => Master Value mbstring.detect_order => no value => no value mbstring.encoding_translation => Off => Off mbstring.func_overload => 0 => 0 mbstring.http_input => pass => pass mbstring.http_output => pass => pass mbstring.http_output_conv_mimetypes => ^(text/|application/xhtml\+xml) => ^(text/|application/xhtml\+xml) mbstring.internal_encoding => no value => no value mbstring.language => neutral => neutral mbstring.strict_detection => Off => Off mbstring.substitute_character => no value => no value openssl OpenSSL support => enabled OpenSSL Library Version => OpenSSL 1.0.1f 6 Jan 2014 OpenSSL Header Version => OpenSSL 1.0.1f 6 Jan 2014 pcre PCRE (Perl Compatible Regular Expressions) Support => enabled PCRE Library Version => 8.37 2015-04-28 Directive => Local Value => Master Value pcre.backtrack_limit => 1000000 => 1000000 pcre.recursion_limit => 100000 => 100000 PDO PDO support => enabled PDO drivers => mysql, pgsql pdo_mysql PDO Driver for MySQL => enabled Client API version => mysqlnd 5.0.11-dev - 20120503 - $Id: bf9ad53b11c9a57efdb1057292d73b928b8c5c77 $ Directive => Local Value => Master Value pdo_mysql.default_socket => /var/run/mysqld/mysqld.sock => /var/run/mysqld/mysqld.sock pdo_pgsql PDO Driver for PostgreSQL => enabled PostgreSQL(libpq) Version => 9.3.14 Module version => 1.0.2 Revision => $Id$ pgsql PostgreSQL Support => enabled PostgreSQL(libpq) Version => 9.3.14 PostgreSQL(libpq) => PostgreSQL 9.3.14 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4, 64-bit Multibyte character support => enabled SSL support => enabled Active Persistent Links => 0 Active Links => 0 Directive => Local Value => Master Value pgsql.allow_persistent => On => On pgsql.auto_reset_persistent => Off => Off pgsql.ignore_notice => Off => Off pgsql.log_notice => Off => Off pgsql.max_links => Unlimited => Unlimited pgsql.max_persistent => Unlimited => Unlimited Phar Phar: PHP Archive support => enabled Phar EXT version => 2.0.2 Phar API version => 1.1.1 SVN revision => $Id: 4b9a493926fec4e6d913722b7a94602c7850c27e $ Phar-based phar archives => enabled Tar-based phar archives => enabled ZIP-based phar archives => enabled gzip compression => disabled (install ext/zlib) bzip2 compression => disabled (install pecl/bz2) Native OpenSSL support => enabled Phar based on pear/PHP_Archive, original concept by Davey Shafik. Phar fully realized by Gregory Beaver and Marcus Boerger. Portions of tar implementation Copyright (c) 2003-2009 Tim Kientzle. Directive => Local Value => Master Value phar.cache_list => no value => no value phar.readonly => On => On phar.require_hash => On => On posix Revision => $Id: 5d20de77687b7d961b15450873fa23b9e64a136a $ readline Readline Support => enabled Readline library => EditLine wrapper Directive => Local Value => Master Value cli.pager => no value => no value cli.prompt => \b \> => \b \> Reflection Reflection => enabled Version => $Id: dc76d2fe0f3e9c327c1d4ca617d94e26c7fae98d $ session Session Support => enabled Registered save handlers => files user Registered serializer handlers => php_serialize php php_binary Directive => Local Value => Master Value session.auto_start => Off => Off session.cache_expire => 180 => 180 session.cache_limiter => nocache => nocache session.cookie_domain => no value => no value session.cookie_httponly => Off => Off session.cookie_lifetime => 0 => 0 session.cookie_path => / => / session.cookie_secure => Off => Off session.entropy_file => /dev/urandom => /dev/urandom session.entropy_length => 32 => 32 session.gc_divisor => 1000 => 1000 session.gc_maxlifetime => 1440 => 1440 session.gc_probability => 0 => 0 session.hash_bits_per_character => 5 => 5 session.hash_function => 0 => 0 session.name => PHPSESSID => PHPSESSID session.referer_check => no value => no value session.save_handler => files => files session.save_path => no value => no value session.serialize_handler => php => php session.upload_progress.cleanup => On => On session.upload_progress.enabled => On => On session.upload_progress.freq => 1% => 1% session.upload_progress.min_freq => 1 => 1 session.upload_progress.name => PHP_SESSION_UPLOAD_PROGRESS => PHP_SESSION_UPLOAD_PROGRESS session.upload_progress.prefix => upload_progress_ => upload_progress_ session.use_cookies => On => On session.use_only_cookies => On => On session.use_strict_mode => Off => Off session.use_trans_sid => 0 => 0 SimpleXML Simplexml support => enabled Revision => $Id: 6b8e23a01a85046737ef7d31346da5164505c179 $ Schema support => enabled SPL SPL support => enabled Interfaces => Countable, OuterIterator, RecursiveIterator, SeekableIterator, SplObserver, SplSubject Classes => AppendIterator, ArrayIterator, ArrayObject, BadFunctionCallException, BadMethodCallException, CachingIterator, CallbackFilterIterator, DirectoryIterator, DomainException, EmptyIterator, FilesystemIterator, FilterIterator, GlobIterator, InfiniteIterator, InvalidArgumentException, IteratorIterator, LengthException, LimitIterator, LogicException, MultipleIterator, NoRewindIterator, OutOfBoundsException, OutOfRangeException, OverflowException, ParentIterator, RangeException, RecursiveArrayIterator, RecursiveCachingIterator, RecursiveCallbackFilterIterator, RecursiveDirectoryIterator, RecursiveFilterIterator, RecursiveIteratorIterator, RecursiveRegexIterator, RecursiveTreeIterator, RegexIterator, RuntimeException, SplDoublyLinkedList, SplFileInfo, SplFileObject, SplFixedArray, SplHeap, SplMinHeap, SplMaxHeap, SplObjectStorage, SplPriorityQueue, SplQueue, SplStack, SplTempFileObject, UnderflowException, UnexpectedValueException sqlite3 SQLite3 support => enabled SQLite3 module version => 0.7-dev SQLite Library => 3.8.10.2 Directive => Local Value => Master Value sqlite3.extension_dir => no value => no value standard Dynamic Library Support => enabled Path to sendmail => -t -i Directive => Local Value => Master Value assert.active => 1 => 1 assert.bail => 0 => 0 assert.callback => no value => no value assert.quiet_eval => 0 => 0 assert.warning => 1 => 1 auto_detect_line_endings => 0 => 0 default_socket_timeout => 60 => 60 from => no value => no value url_rewriter.tags => a=href,area=href,frame=src,input=src,form=fakeentry => a=href,area=href,frame=src,input=src,form=fakeentry user_agent => no value => no value tokenizer Tokenizer Support => enabled xml XML Support => active XML Namespace Support => active libxml2 Version => 2.9.1 xmlreader XMLReader => enabled xmlwriter XMLWriter => enabled Zend OPcache Opcode Caching => Disabled Optimization => Disabled Startup Failed => Opcode Caching is disabled for CLI Directive => Local Value => Master Value opcache.blacklist_filename => no value => no value opcache.consistency_checks => 0 => 0 opcache.dups_fix => Off => Off opcache.enable => On => On opcache.enable_cli => Off => Off opcache.enable_file_override => Off => Off opcache.error_log => no value => no value opcache.fast_shutdown => 0 => 0 opcache.file_update_protection => 2 => 2 opcache.force_restart_timeout => 180 => 180 opcache.inherited_hack => On => On opcache.interned_strings_buffer => 4 => 4 opcache.load_comments => 1 => 1 opcache.log_verbosity_level => 1 => 1 opcache.max_accelerated_files => 2000 => 2000 opcache.max_file_size => 0 => 0 opcache.max_wasted_percentage => 5 => 5 opcache.memory_consumption => 64 => 64 opcache.optimization_level => 0xFFFFFFFF => 0xFFFFFFFF opcache.preferred_memory_model => no value => no value opcache.protect_memory => 0 => 0 opcache.restrict_api => no value => no value opcache.revalidate_freq => 2 => 2 opcache.revalidate_path => Off => Off opcache.save_comments => 1 => 1 opcache.use_cwd => On => On opcache.validate_timestamps => On => On Additional Modules Module Name Environment Variable => Value HOSTNAME => 1866210b51f6 APACHE_RUN_USER => www-data TERM => xterm PATH => /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PWD => / APACHE_RUN_GROUP => www-data SHLVL => 1 HOME => /root no_proxy => *.local, 169.254/16 _ => /usr/bin/php PHP Variables Variable => Value _SERVER["HOSTNAME"] => 1866210b51f6 _SERVER["APACHE_RUN_USER"] => www-data _SERVER["TERM"] => xterm _SERVER["PATH"] => /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin _SERVER["PWD"] => / _SERVER["APACHE_RUN_GROUP"] => www-data _SERVER["SHLVL"] => 1 _SERVER["HOME"] => /root _SERVER["no_proxy"] => *.local, 169.254/16 _SERVER["_"] => /usr/bin/php _SERVER["PHP_SELF"] => - _SERVER["SCRIPT_NAME"] => - _SERVER["SCRIPT_FILENAME"] => _SERVER["PATH_TRANSLATED"] => _SERVER["DOCUMENT_ROOT"] => _SERVER["REQUEST_TIME_FLOAT"] => 1492057434.5263 _SERVER["REQUEST_TIME"] => 1492057434 _SERVER["argv"] => Array ( [0] => - ) _SERVER["argc"] => 1 

由于我们使用PHP进行编译,所以禁止加载cURL扩展

sed -i“s / extension = curl.so /; extension = curl.so / g”/etc/php5/apache2/conf.d/20-curl.ini

我运行这个命令,从我发现加载扩展的20-curl.ini文件中禁用它。 我在Dockerfile的运行脚本中做了这个。