(SOLVED BELOW) I am stuck for a few days now trying to effectively use composer to install phpspreadsheet on a php project I am working on for a client. Since phpspreadsheet requires php >= 7.2 I installed multiple versions of php (5.6, 7.1,2,3,4, 8.0) on my Linux drive (ubuntu 20.04.2 LTS focal). I uninstalled an Ampps server which only had php7.1. Apache2 was already installed. I installed mysql-server 8.0 after some difficulties (until I purged the ampps installation).
Composer did install globally, and I did initialize a basic composer.json in my webroot directory. A /vendor
dir was created containing a /composer
dir.
My most recent composer.json file:
{
"name": "john/t.cga.it8",
"description": "cga website",
"type": "project",
"license": "proprietary",
"authors": [
{
"name": "John Loughran",
"email": "example@gmail.com"
}
],
"minimum-stability": "dev",
"require": {}
}
If I run $ composer diagnose
from the web root dir in the terminal I got the following error:
[Composer\Exception\NoSslException]
The openssl extension is required for SSL/TLS protection but is not available. If you can not enable the openssl extension, you can disable
this error, at your own risk, by setting the 'disable-tls' option to true.
Attempts to run $ composer update
or upgrade
stall with the same error.
When, as suggested, I configure composer to run without SSL using $ composer config -g -- disable-tls true
I get the following, in full technicolor:
You are running Composer with SSL/TLS protection disabled.
Checking composer.json: OK
Checking platform settings: FAIL
The openssl extension is missing, which means that secure HTTPS transfers
are impossible.
If possible you should enable it or recompile php with --with-openssl
The zlib extension is not loaded, this can slow down Composer a lot.
If possible, enable it or recompile php with --with-zlib
A php.ini file does not exist. You will have to create one.
If you can not modify the ini file, you can also run `php -d option=value`
to modify ini values on the fly. You can use -d multiple times.
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: FAIL
[Composer\Downloader\TransportException] The "https://repo.packagist.org
/packages.json" file could not be downloaded: Unable to find the wrapper
"https" - did you forget to enable it when you configured PHP?
failed to open stream: No such file or directory
Composer is configured to disable SSL/TLS protection. This will leave
remote HTTPS requests vulnerable to Man-In-The-Middle attacks.
Checking github.com rate limit: FAIL
[Composer\Downloader\TransportException] The "https://api.github.com
/rate_limit" file could not be downloaded: Unable to find the wrapper
"https" - did you forget to enable it when you configured PHP?
failed to open stream: No such file or directory
Checking disk free space: OK
Checking pubkeys:
Tags Public Key Fingerprint: <I removed the public keys here and below>
Dev Public Key Fingerprint:
OK
Checking composer version: Warning: Accessing getcomposer.org over http which is an insecure protocol.
OK
Composer version: 2.0.14
PHP version: 7.4.16
PHP binary path: /usr/local/bin/php
OpenSSL version: missing
cURL version: missing, using php streams fallback, which reduces performance
zip: extension not loaded, unzip present
To answer some of the points in the errors:
Openssl IS installed, using snaps, in non standard locations. From the browser the php function
loaded_extension('openssl')
returns true. Based on advice from https://www.php.net/manual/en/imap.requirements.php I made a symlink from where I found the openssl file as:$ ln -s /usr/bin/openssl /usr/local/ssl
and similarly$ ln -s /usr/local/ssl/include /usr/include/openssl
.Based on advice from Luke Welling's books I installed JPEG, PNG, IMAP and zlib libraries.
To address the php.ini "missing" issue, from the terminal I got:
john@john-desktop:~$ php7.4 -i | grep -i openssl
Warning: PHP Startup: Unable to load dynamic library 'openssl' (tried:
/usr/lib/php/20190902/openssl (/usr/lib/php/20190902/openssl: cannot open
shared object file: No such file or directory), /usr/lib/php/20190902
/openssl.so (/usr/lib/php/20190902/openssl.so: cannot open shared object
file: No such file or directory)) in Unknown on line 0
SSL Version => OpenSSL/1.1.1f
libSSH Version => libssh/0.9.3/openssl/zlib
openssl
OpenSSL support => enabled
OpenSSL Library Version => OpenSSL 1.1.1f 31 Mar 2020
OpenSSL Header Version => OpenSSL 1.1.1f 31 Mar 2020
Openssl default config => /usr/lib/ssl/openssl.cnf
openssl.cafile => no value => no value
openssl.capath => no value => no value
Native OpenSSL support => enabled
Perhaps my symlinks are wrong? Some configuration seems wrong but I am not sure how to fix it.
I do have php.ini files. For php7.4 the main one that phpinfo() shows is loading (in the browser) is in /etc/php/7.4/fpm/
. I have left this unaltered but added a phpcustomjl.ini
file (with priority 01) in /etc/php/7.4/mods-enabled/
which is symlinked by the system from /etc/php/7.4/fpm/conf.d/
. It shows up in phpinfo() from the browser among the Additional .ini files parsed. I learned to use $ sudo systemctl restart php7.4-fpm
after making changes to it, so that these changes take effect. The relevant lines from the .ini file are:
extension=zlib
;extension=/usr/lib/ssl
;extension=/usr/bin/openssl
extension=openssl
;extension=php_openssl
$ php7.4 --ini
shows that this file is loaded in the cli. It outputs:
Warning: PHP Startup: Unable to load dynamic library 'openssl' (tried: /usr/lib/php/20190902/openssl (/usr/lib/php/20190902/openssl: cannot open shared object file: No such file or directory), /usr/lib/php/20190902/openssl.so (/usr/lib/php/20190902/openssl.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Warning: Module 'curl' already loaded in Unknown on line 0
Configuration File (php.ini) Path: /etc/php/7.4/cli
Loaded Configuration File: /etc/php/7.4/cli/php.ini
Scan for additional .ini files in: /etc/php/7.4/cli/conf.d
Additional .ini files parsed: /etc/php/7.4/cli/conf.d/01-phpcustomjl.ini,
This shows that the custom ini file is being read from the cli, so some setting in it must be faulty perhaps?
- When I run
$ php -v
in the terminal I getPHP 7.4.16 (cli)
. In the browser when I want to enable php7.4 (as it is currently) I use a.htaccess
file in the web root, withSetHandler "proxy:unix:/var/run/php/php7.4-fpm.sock|fcgi://localhost/"
in a directive.
I hope I have enough details for someone to figure out the problem, or suggest any strategies. Until then I am stuck! Any help you can offer would be greatly appreciated. :-) John