Category Archives: PHP

[Solved] PHP getimagesize(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL

Today, I encountered a problem with the client application server (CentOS). When using getimagesize(), an error is always reported:

PHP getimagesize(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_ get_ server_ certificate:certificate verify failed

It is preliminarily judged that openssl.cafile in php.ini is not set. After opening the PHP configuration file, it is found that it is set. The current setting value is:

openssl.cafile=/etc/pki/tls/certs/ca-bundle.crt

After that, it was suspected that the certificate might expire. First, compare the contents of the file on your own server. If you find that the size is inconsistent, copy and paste the contents from your own server. After saving, the problem of reloading PHP configuration still exists;

Remember that similar problems have occurred on Windows systems before. At that time, curl.cainfo was configured, so from this website
: http://curl.haxx.se/ca/cacert.pem Download the certificate and put it in the /usr/local/OpenSSL/ directory to modify the configuration

[curl]
curl.cainfo = /usr/local/openssl/cacert.pem

[openssl]
openssl.cafile=/usr/local/openssl/cacert.pem

When this problem occurs on the Internet, the solutions found are also operated in this way. However, the overload configuration problem remains after saving. Change the configuration back again.

Finally, see this article on: https://stackoverflow.com/questions/17084886/ssl-error-routinesssl3-get-server-certificatecertificate-verify-failed

It is found that the Linux system has the command to update the local certificate. The commands are different for different systems. The CentOS operation is as follows:

#Install ca certificate tool
yum install ca-certificates -y

# Update Certificate
update-ca-trust

Problem-solving.

[WordPress Error] Fatal error undefined function is_network_admin()

Fatal error undefined function is_network_admin()

Problem Description:

When you upgrade WordPress, a fatal error undefined function is displayed when you try to log in_network_Admin() fatal error.

Solution: upgrade manually

This error is caused by the WordPress upgrade failure. Try upgrading manually.

1. Download the latest WordPress package and unzip it.

2. Back up your current WordPress.

3. Rename the WP includes and WP admin directories to WP includes.bak and wp-admin.bak.

4. Upload WP includes and WP admin directories to the server via FTP.

5. Upload the contents of the new WP content directory to the corresponding location on the server.

6. Upload other files to the WordPress root directory.

7. Delete the. Maintenance file through FTP.

8. Log in to WordPress again and you will see a link like http://your domain name/WordPress/WP admin/upgrade.php. Follow the instructions.

9. Empty the cache and see if you have taken effect.

[Solved] PHP -v Error: error while loading shared libraries: libonig.so.5:cannot open share directory

When upgrading from PHP 5.6 to PHP 7.4, you can directly replace the compiled installation package. When you enter PHP – V, you will report an error while loading shared libraries: libonig. So. 5: cannot open share directory

#php -v
#php: error while loading shared libraries: libonig.so.5:cannot open share directory

Solution:

Step 1

Modify /ect/ld.so.conf     Add the following line

#vim /etc/ld.so.conf
include ls.so.conf.d/*.conf
/usr/local/lib
/usr/local/x264/lib
/usr/local/openssl/lib
/usr/local/python3.7.1/lib

After saving   Execute ldconfig

#ldconfig

Step 2:

Install oniguruma library

Download Link:

https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/o/oniguruma-devel-6.8.2-1.el7.x86_64.rpm

https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/o/oniguruma-6.8.2-1.el7.x86_64.rpm

oniguruma-6.8.2-1.el7.x86 64.rpm

oniguruma-devel-6.8.2-1.el7.x86 64.rpm

Use the follow commands to install:

#rpm -ivh oniguruma-devel-6.8.2-1.el7.x86_64
#rpm -ivh oniguruma-6.8.2-1.el7.x86_64

Then run the command PHP – V     Perfect display

If installation error

Generating autotools files.
./autogen.sh: line 6: autoreconf: command not found

Solution:

[root@yjweb oniguruma-6.9.4]# yum install autoconf automake libtool

[Solved] PHP installation Phalcon expansion error

sudo apt-get install php7.1-phalcon
sudo: unable to resolve host official
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package php7.1-phalcon
E: Couldn’t find any package by glob ‘php7.1-phalcon’
E: Couldn’t find any package by regex ‘php7.1-phalcon’ 

Solution:
sudo apt-get install curl
curl -s https://packagecloud.io/install/repositories/phalcon/stable/script.deb.sh | sudo bash
sudo apt-get install php7.1-phalcon

[Solved] Fatal error: Uncaught Error: Class ‘Imagick‘ not found

Resolve fatal error: uncaught error: class’ imageick ‘not found

reason

PHP requires the imageick extension to be installed

environment

CentOS Linux release 7.9
PHP 7.3.26

Installation steps

Download the appropriate ImageMagick program and ImageMagick extension according to the environment

Installing imagemagic

wget http://www.imagemagick.org/download/ImageMagick.tar.gz

tar zxvf ImageMagick.tar.gz 
cd ImageMagick-7.1.0-8/
./configure --prefix=/usr/local/webservice/imagemagick
make && make install

Check whether the installation is successful

/usr/local/webservice/imagemagick/bin/convert -version

Version: ImageMagick 7.1.0-8 Q16-HDRI x86_64 2021-09-18 https://imagemagick.org
Copyright: (C) 1999-2021 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP(3.1) 
Delegates (built-in): fontconfig freetype jng jpeg lzma png x xml zlib
Compiler: gcc (4.8)

Installing the PHP extension: imagick

Download address

https://pecl.php.net/package/imagick
View the appropriate version download

 wget https://pecl.php.net/get/imagick-3.5.1.tgz
 tar zxvf imagick-3.5.1.tgz

cd imagick-3.5.1/
/usr/local/webservice/php73/bin/phpize
./configure --with-php-config=/usr/local/webservice/php73/bin/php-config --with-imagick=/usr/local/webservice/imagemagick
make && make install

Successful installation is displayed

Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /usr/local/webservice/php73/lib/php/extensions/no-debug-zts-20180731/
Installing header files:          /usr/local/webservice/php73/include/php/

Modify the configuration file and write extension=imagick.so

Add
extension=/usr/local/webservice/php73/lib/php/extensions/no-debug-zts-20180731/imagick.so at the end of vim /usr/local/webservice/php73/etc/php.ini

Restart php-fpm and test whether the installation is successful
systemctl restart php-fpm

php -m | grep imagick

Error during session start; please check your PHP and/or webserver log file and configure your PHP

Environment: Windows Server 2008 R2 IIS7.5 PHP7.3+
Error:
Error during session start; please check your PHP and/or webserver log file and configure your PHP installation properly. Also ensure that cookies are enabled in your browser.
Solution:
Permissions problem, Windows – temp set IIS_IUSRS write permissions, solved.

[Solved] PHP Fatal error: Uncaught Error: Class ‘Redis‘ not found in

The problem is that the redis class cannot be captured in the message

However, I have installed redis and used it in PHP code, but when I execute PHP jifen.php in Linux system, I report that redis class cannot be found.

Solution:

First, determine if there are two PHP in your system.

find/-name php

Then find your current PHP Directory:

Use phpinfo () in the PHP file; Method, you can access it

My PHP files are at /www/server/PHP/73/

Modify the system environment file:/etc/profile

vi /etc/profile

Write the PHP environment address to the end of the configuration file


The PHP runtime files are inside the bin directory, so mine is: /www/server/php/73/bin/

export PATH=$PATH:your PHP address

Save, exit, and then run:

source /etc/profile

Restart the PHP file to use PHP jifen.php

 

[Solved] Type error: Argument 1 passed to Monolog\Utils::getClass() must be an instance of Monolog\object

Type error: Argument 1 passed to Monolog\Utils::getClass() must be an instance of Monolog\object


Error reason.
Because the PHP version is too high, 2.x minimum requirement PHP7.2 The official original words are as follows:

https://github.com/Seldaek/monolog
Requirements
Monolog ^2.0 works with PHP 7.2 or above, use Monolog ^1.25 for PHP 5.3+ support.

Solution:
composer downgrade monolog/monolog version

"require": {
    "monolog/monolog": "^1.25",
}

TP5 fuzzy Chinese characters error [How to Solve]

When using TP5 to fuzzy query Chinese characters, sometimes some Chinese characters will report errors, which are placeholder errors, so modify the paging style;

Modify the bootrapthink.php file

return sprintf(
//                    '<div id="page" class="page_div pagination">%s %s %s<span class=\'totalSize\'> 跳转<input class=\'jump_class jump_page_num\' οnkeyup="this.value=this.value.replace(/\D/, \'\');" type=\'text\' value=\'\'>页 </span><a href=\'javascript:void(0);\' οnclick=\'jumpPage(this);\' data-href="'.$base_url.'" class=\'jump_btn\' style=\'color: #18a689;border: 1px solid #18a689!important;margin-left:0px;\'>确定</a><span class="totalPages"> 共<span>'.$this->lastPage.'</span>页 </span><span class="totalSize"> 共<span>'.$this->total.'</span>条记录 </span></div>',
//                    $this->getPreviousButton(),
//                    $this->getLinks(),
//                    $this->getNextButton()

Sometimes you will find something wrong with his placeholder

Change to:

return '<div id="page" class="page_div pagination">'.$this->getPreviousButton().' '.$this->getLinks().' '.$this->getNextButton().'<span class=\'totalSize\'> 跳转<input class=\'jump_class jump_page_num\' οnkeyup="this.value=this.value.replace(/\D/, \'\');" type=\'text\' value=\'\'>页 </span><a href=\'javascript:void(0);\' οnclick=\'jumpPage(this);\' data-href="'.$base_url.'" class=\'jump_btn\' style=\'color: #18a689;border: 1px solid #18a689!important;margin-left:0px;\'>确定</a><span class="totalPages"> 共<span>'.$this->lastPage.'</span>页 </span><span class="totalSize"> 共<span>'.$this->total.'</span>条记录 </span></div>';

With specific analysis of the situation, finally, I wish you all a smooth work!

[Solved] WordPress Upgrade PHP 5.6 to 7.x Fatal error: Uncaught Error: Call to undefined function mysql_connect()

Error reporting when upgrading PHP version 5.6 to 7. X under WordPress (resolved)

Cause of event:

When using WordPress, the theme needs to be upgraded. The PHP version required for viewing the theme is 7.1+

When the website is not backed up, the PHP version is changed to 7.2, which directly leads to the website error

Fatal error: Uncaught Error: Call to undefined function mysql_ connect()

Check many online tutorials, which are MySQL in wp-db.php_Change connect() to mysqli_Connect(), no result

At first, I thought that the database reported an error, checked the database in detail, wrote checkdb.php, locally connected to the database, and checked that the database server was running well

Solution:

Set define ('wp_use_ext_mysql ', true) in wp-config.php delete

error explanation:

define('WP_USE_EXT_MYSQL',true);

define(‘WP_USE_EXT_MYSQL’, true); Force WP to use MySQL by default instead of MySQL Li
so please delete this line and the problem should be solved.

Otherwise, you can check nd in the PHP 7 configuration_Mysqli extension, and disable mysqli extension – > Select the PHP version.

Error while injecting dependencies into App\Controller\IndexController: No entry or class found for

An error occurs when a service consumer class is manually created for the hyperf 2.2.0 microservice.

In the documentation on the official website, when manually creating a consumer class, its recommended configuration of services.php is as follows.

<?php
return [
    'consumers' => [
        [
            'name' => 'CalculatorService',
            'registry' => [
                'protocol' => 'consul',
                'address' => 'http://127.0.0.1:8500',
            ],
            'nodes' => [
                ['host' => '127.0.0.1', 'port' => 9504],
            ],
        ]
    ],
];

Later, I saw the video on the official website jsonrpc. The recommendation in the video is as follows.

<?php
return [
    'consumers' => [
        [
            'name' => 'CalculatorService',
            'nodes' => [
                ['host' => '127.0.0.1', 'port' => 9504],
            ],
        ]
    ],
];

I wonder if the above writing is only applicable to the 1. X.x era?When I upgrade to 2.2.0, it is reported above

[ERROR] Error while injecting dependencies into App\Controller\IndexController: No entry or class found for ‘App\Rpc\CalculatorServiceInterface'[101]

After tossing for a long time, I found that there are few services.php configurations

    'service' => \App\Rpc\CalculatorServiceInterface::class,

So, don’t lose service. The complete services.php is like this

return [
    'consumers' => [
        [
            // name needs to be the same as the name attribute of the service provider
            'name' => 'CalculatorService',
            // service interface name, optional, default value is equal to the value configured by name, if name is defined directly as an interface class then this line can be ignored, if name is a string then you need to configure service to correspond to the interface class
            'service' => \App\Rpc\CalculatorServiceInterface::class,
            // corresponding to the container object ID, optional, default value is equal to the service configuration value, used to define the dependency injection key
            'id' => \App\Rpc\CalculatorServiceInterface::class,
            // Service protocol of the service provider, optional, default value is jsonrpc-http
            // optional jsonrpc-http jsonrpc jsonrpc-tcp-length-check
            'protocol' => 'jsonrpc-http',
            // load balancing algorithm, optional, default value is random
// 'load_balancer' => 'random',
            // which service center this consumer will get the node information from, if not configured it will not get the node information from the service center
// 'registry' => [
// 'protocol' => 'consul',
// 'address' => 'http://127.0.0.1:8500',
// ],
            // If the above registry configuration is not specified, i.e., the node is consumed directly for the specified node, and the node information of the service provider is configured with the following nodes parameter
            'nodes' => [
                ['host' => '127.0.0.1', 'port' => 9504],
            ],
        ]
    ],
];

Run later and run through

[Solved] Fatal error: Class ‘think\Container‘ not found & [InvalidArgumentException] Could not find package

Fatal error: class’ think \ container ‘not found. This error means that the ThinkPHP core framework warehouse is not a branch of version 5.1, so the container of version 5.1 is not found;

The solution is to execute the following command on the terminal terminal of the IDE:

composer create-project topthink/think tp 5.1.35

Starting from tp5.1, the official website no longer provides a full version download, but can only be installed through the composer method.

[invalidargumentexception] could not find package. This error means that the installation package of the corresponding version is not found. The problem in the figure below is that the version number behind 5.1 is missing. It is correct after supplement as shown in the figure above.

  The program operation after correct input is as follows: