Category Archives: PHP

[Solved] Composer Install Error: PHP Warning: copy(): SSL operation failed with code 1. OpenSSL Error messages:

Problem description

#php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"

PHP Warning:  copy(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in Command line code on line 1
PHP Warning:  copy(): Failed to enable crypto in Command line code on line 1
PHP Warning:  copy(https://install.phpcomposer.com/installer): failed to open stream: operation failed in Command line code on line 1

Solution:

Download certificate http://curl.haxx.se/ca/cacert.pem 
wget http://curl.haxx.se/ca/cacert.pem
Or use the web page to download and upload to linux
mkdir -p /usr/local/openssl/ssl/certs/
mv cacert.pem /usr/local/openssl/ssl/certs/cacert.pem

Modify php.ini

;openssl.capath=
openssl.cafile=/usr/local/openssl/ssl/certs/cacert.pem

Problem-solving

Reinstall the composer

Thinkphp6 Error: constraint violation: 1052 Column ‘id’ in where clause is ambiguous

Cause

Show a column model

<?php
declare (strict_types=1);

namespace app\model;

use think\Model;

/**
 * @mixin \think\Model
 */
class Column extends Model
{

    public function articles()
    {

        return $this->belongsToMany(Article::class, 'column_article', 'article_id', 'column_id');
    }


    public function hasArt($article_id)
    {
        return $this->articles()->where('id', $article_id)->count();
    }

}

Wrong package when using

constraint violation: 1052 Column 'id' in where clause is ambiguous...

The reason for the error is that the relationship model of ThinkPHP does not know which table ID it is,

Here, we need to know which table it belongs to when sorting, so we also need to specify the table name when using it (Note: it needs to be prefixed)

    public function hasArt($article_id)
    {
        return $this->articles()->where('lu_article.id', $article_id)->count();
    }

[Solved] PHP Hprose Client Error: ‘Tag ‘RAEz’ expected

When the client requests the server, an error appears: (tag ‘raez’ expected, but ‘this error can be seen

1. Is the comment on the always_populate_raw_post_data configuration in php.ini opened?If not, you can!

2. If you continue to report the error according to the above modification, it is sufficient to check the user’s permission to the project. After the landlord modifies the Chmod – R 777 project name with the command, the project can be accessed normally.

PHP5.6.27 Install error: error: dereferencing pointer to incomplete type ‘EVP_PKEY’ {aka ‘struct evp_pkey_st’}

Php5.6.27 make && Make install reports an error and cannot be resolved. The error contents are as follows:

/usr/develop/php-5.6.27/ext/openssl/openssl.c:3485:14: error: dereferencing pointer to incomplete type 'EVP_PKEY' {aka 'struct evp_pkey_st'}
  switch (pkey->type) {
              ^~
/usr/develop/php-5.6.27/ext/openssl/openssl.c: In function 'php_openssl_pkey_init_dsa':
/usr/develop/php-5.6.27/ext/openssl/openssl.c:3557:10: error: dereferencing pointer to incomplete type 'DSA' {aka 'struct dsa_st'}
  if (!dsa->p || !dsa->q || !dsa->g) {
          ^~
/usr/develop/php-5.6.27/ext/openssl/openssl.c: In function 'php_openssl_pkey_init_dh':
/usr/develop/php-5.6.27/ext/openssl/openssl.c:3580:9: error: dereferencing pointer to incomplete type 'DH' {aka 'struct dh_st'}

Reason: php5.6.27 and OpenSSL 1.1.1c are incompatible.

I checked my OpenSSL version:

[root@node3 php-5.6.27]# openssl version
OpenSSL 1.1.1c FIPS  28 May 2019

Preliminary solution: downgrade the version of OpenSSL. I chose openssl-1.0.0c. Recompile the installation and there will be no compilation errors.

yum remove -y openssl
cd /usr/apps/
wget -c ftp://ftp.openssl.org/source/openssl-1.0.0c.tar.gz
tar -zxf openssl-1.0.0c.tar.gz
cd openssl-1.0.0c/
./config  --prefix=/usr/local --openssldir=/usr/local/ssl
make && make install
./config shared --prefix=/usr/local --openssldir=/usr/local/ssl
make clean 
make && make install
openssl version # check the version

It’s useless to find. There are always all kinds of problems

Final solution: install php7.3.13

[Solved] include(../template/header.html): failed to open stream: No such file or dir…

Introduce the problem of the path. It is recommended to join

include  $_SERVER[‘DOCUMENT_ROOT’].”/template/header.html”;

It means to get include.PHP. In the root of the website

        // Wrong
        // include('../template/header.html');
        // Right
        include $_SERVER['DOCUMENT_ROOT']."/template/header.html";

How to Solve PHP 500 Error

PHP 500 error reporting solution

1. First look at the error log file path specified by nginx error.log, find the log file, look at the information inside
2, and then look at the path of PHP error log specified in php-fpm.conf
as follows

php_flag[display_errors] = off
php_admin_flag[log_errors] = on
php_admin_value[error_log] = /data/logs/fpm-php.log

the in php.ini is invalid. Use PHP FPM to control it