Tag 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.

PHP function file_ get_ Contents() reports an error when using HTTPS protocol: SSL operation failed

Scenario:

file_ get_ The contents () function is used to read the contents of a file into a string. It is one of the commonly used functions to read the contents of a file.

But sometimes file is used on the server_ get_ When the contents() function requests the URL file of HTTPS protocol, an error will be reported, and the file content cannot be read correctly,

reason:

The server is not properly configured with HTTPS certificate

Solution: (three solutions)

Method 1:

Download HTTPS certificate to server

The server downloads this certificate, http://curl.haxx.se/ca/cacert.pem
Php.ini configuration
openssl.cafile = “/ etc/SSL/certs/cacert. PEM”// the path where you actually download the certificate
Restart PHP

Method 2:

Use the curl function to process HTTPS parameters and obtain the file content

<?php
function getSSLPage($url) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_SSLVERSION,3); 
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}

var_dump(getSSLPage("https://xxx.xxx.xxx"));
?>

Method 3:

Make file_ get_ The contents() function skips HTTPS authentication

$stream_opts = [
    "ssl" => [
        "verify_peer"=>false,
        "verify_peer_name"=>false,
    ]
]; 

$response = file_get_contents("https://xxx.xxx.xxx",false,stream_context_create($stream_opts));

  It is recommended to use curl function instead of file in development_ get_ Contents() function.

The installation of ThinkPHP reported an error. Could not find package topthink / think with stability stable

Install ThinkPHP and execute the command

composer create-project topthink/think tp5 --prefer-dist

report errors

 [InvalidArgumentException]
Could not find package topthink/think with stability stable.

resolvent:

    delete the previous image

    composer config -g --unset repos.packagist
    
      run the install ThinkPHP command

      composer create-project topthink/think tp5 --prefer-dist
      

      success!!!

[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

cURL error 60: SSL certificate problem: self signed certificate in certificate chain

1、 Question

Curl error 60: SSL certificate problem: self signed certificate in certificate chain – server http302 this is generally a problem with self signed certificates

2、 Settle

Scheme 1. Directly use the domain name with HTTPS on the online server

Solution 2. Windows local development environment solution

a) Download certificate:
https://github.com/china-li-shuo/ca-cert

b) Put the downloaded Certificate in your PHP path:

D: \ wamp64 \ bin \ PHP \ php7.3.21 \ extras \ SSL this is your local PHP version path

c) Modify the php.ini file

curl.cainfo ="D:\wamp64\bin\php\php7.3.21\extras\ssl\ca-cert.crt"
openssl.cafile="D:\wamp64\bin\php\php7.3.21\extras\ssl\ca-cert.crt"

d) Just restart PHP

Using the TP framework, an error is reported sqlstate [08004] [1040] too many connections

Use
when MySQL inserts a large amount of data and needs to compare and duplicate          Db($table)-> where($where)-> find();

In this case, an error will be reported: sqlstate [08004] [1040] too many connections

This is mainly due to too many database connections

resolvent:

        Introduce DB class

                 use think\Db;

        The query statement is changed to:

                 Db::table($table)-> where($where)-> find();

That’s it

[Solved] Error during composer operation in docker: insufficient memory

Background
Need to perform composer removal package operation on lumen framework.
Error message

docker composer remove Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 byt

Solution:

/usr/local/bin/php -d memory_limit=-1 /usr/local/sbin/composer remove xxx

Explanation: php -d memory_limit=-1 means that the php process uses unlimited memory.
Note that both php and composer need to use absolute paths.

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