php.ini file, Composer, and allow_url_fopen=0

StephenW

Registered
Oct 10, 2019
2
1
3
Oregon
cPanel Access Level
Website Owner
Hi,
I am new here. I have a problem, I am trying to get the Composer PHP Dependency Manager to self-update and to perform the other tasks that it is designed to do. However, it is not working. I don't know much about this and I'm trying to figure this out. I'd appreciate any help that you can give. From an amateur's point of view, I think that there are some settings and/or files in cPanels/files that need to be fixed or corrected, etc. I think that at least part of the problem is getting "allow_url_fopen=0" set correctly in the php.ini file. I am trying to give as much detail as possible so that you can show me what the problem is or what I am doing wrong and what I should do to fix it.

Here is what I have been trying:
I am trying to get Composer working in my shared hosting cPanel account. Composer was installed a little over a year ago, but I haven't used it. I've only recently been trying to learn how to use it. Only I'm having problems with getting it to work and I think that problem have to be solved in cPanel first. After that I'll work on getting Composer working and learning it.

First, I'm trying to update composer to the lastest version. Using PuTTY, from within the cPanel files home directory I entered [~]# composer self-update. This was the error message that I received.

Code:
  [Composer\Downloader\TransportException]
  The "https://getcomposer.org/versions" file could not be downloaded: allow_url_fopen must be enabled in
   php.ini (https:// wrapper is disabled in the server configuration by allow_url_fopen=0
  failed to open stream: no suitable wrapper could be found)
Trying to learn a little more about the problem, I entered [~]# composer diagnose into PuTTy. I received this message:
Code:
Checking platform settings: FAIL

The allow_url_fopen setting is incorrect.
Add the following to the end of your `php.ini`:
    allow_url_fopen = On
So, I went into the cPanel main window and under the Software Category, I found the MultiPHP INI Editor, which I opened. In the "Editor Mode" window I chose the --Select a location-- menu and then chose "Home Directory"

Path /home/username/php.ini PHP Version ea-php72

This is the text of the php.ini file that is in the cPanel Files home directory:
Code:
 1  ; cPanel-generated php ini directives, do not edit
2  ; Manual editing of this file may result in unexpected behavior.
3  ; To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
4  ; For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
5
6  display_errors = On
7  display_startup_errors = Off
8  ignore_repeated_errors = 0
9  upload_tmp_dir = /home/winterss/php_temp
10  php_value_memory_limit = "128M"
11  max_execution_time = 30
12  max_input_time = 60
13  max_input_vars = 1000
14  memory_limit = 256M
15  post_max_size = 8M
16  session.gc_maxlifetime = 1440
17  session.save_path = "/var/cpanel/php/sessions/ea-php72"
18  upload_max_filesize = 2M
19  zlib.output_compression = On
20  allow_url_fopen = 0
21  ; I, Stephen, added this last line above this line
I had previously added lines 20 & 21, which had no effect. When I tried to do other [~]# composer self-update I still had the below error:
Code:
[Composer\Downloader\TransportException]
  The "https://getcomposer.org/versions" file could not be downloaded: allow_url_fopen must be enabled in php.ini (https:// wrapper is disabled in the server configu
  ration by allow_url_fopen=0
  failed to open stream: no suitable wrapper could be found)
Could someone help me figure out how to get the settings and or files corrected or installed so that I can start on getting Composer working and learning it? Thanks.

Best Wishes,
Stephen
An upholsterer by trade, but computers and websites are two of my passions

Composer version 1.7.3 2018-11-01 10:05:06
Using cPanel on a shared hosting account
cPanel Version: 82.0 (build 16)
Apache Version: 2.4.41
PHP Version: 7.2.22
MySQL Version: 10.3.18-MariaDB-log
Architecture: x86_64
Operating System: linux
Perl Version: 5.10.1
Kernel Version: 2.6.32-754.22.1.el6.x86_64
 
Last edited:

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,266
313
Houston
My assumption here is that your provider has allow_url_fopen disabled in the global php.ini for ea-php72. This isn't something you'd be able to modify, you'd need to contact them to do this.

The global php.ini takes precedence over the local one you're adding so if its disabled you'll not be able to override that setting.
 

StephenW

Registered
Oct 10, 2019
2
1
3
Oregon
cPanel Access Level
Website Owner
My assumption here is that your provider has allow_url_fopen disabled in the global php.ini for ea-php72. This isn't something you'd be able to modify, you'd need to contact them to do this.

The global php.ini takes precedence over the local one you're adding so if its disabled you'll not be able to override that setting.
Thank you Lauren for responding. I'll give your suggestion a try.
Stephen
 
  • Like
Reactions: cPanelLauren

carock

Well-Known Member
Sep 25, 2002
266
9
168
St. Charles, MO
In your answer, you say the global takes precedence. Wouldn't that mean nothing in a local user php.ini will work then? Only global setting works?
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,266
313
Houston
In your answer, you say the global takes precedence. Wouldn't that mean nothing in a local user php.ini will work then? Only global setting works?
In some instances....yes but it depends on what the circumstance is. For example, if I set the php_memory_limit for PHP 7.3 globally to 850M then set it for the site in the local .ini file to 256M -> the local .ini file value will take precedence. Alternatively, if I set it to 900M locally the global will take precedence.

With that being said, for this setting allow_url_fopen if I disable this globally for php 7.3 no account will be able to utilize it. If I enable it globally for php 7.3 I can disable it per account with a local ini file.

The local ini file is respected but will not honor values outside of the constraints of the global.

Thanks!
 

carock

Well-Known Member
Sep 25, 2002
266
9
168
St. Charles, MO
ok, that makes sense. Thank you for clarifying.

is there a list of php values that are only global where the local ini has no influence or is that just anything that is not shown in the user's cpanel multi-php ini settings.

Thanks,
Chuck