upgrade server php version in Cpanel - php

I have to run composer in cpanel terminal to install and host laravel project. But however, it gives this error This package requires php ^7.2.5 but your PHP version (5.6.40) does not satisfy that requirement.
I go Settings >> MultiPHP Manager and select my domain and upgrade PHP version to 7.3
I check my PHP version in ~
[myuser#server ~]$ php -v
PHP 5.6.40 (cli) (built: May 5 2020 19:25:18)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
I go to public_html/www (where my laravel project is placed)
[myuser#server www]$ php -v
PHP 7.3.18 (cli) (built: May 21 2020 03:33:34) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.18, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.18, Copyright (c) 1999-2018, by Zend Technologies
I go to server_information under General Information and the PHP version is 5.6,
so my question is
How to upgrade server PHP version from 5.6 to 7.3
Please note that I don't have root access, and also ApacheEasy4 is also not accessible by my user in Server.
My MultiPHP Manager Image

if in "phpversion" function you see the version of php is 7.x, but in composer is 5.x: it's because your server manager has set default php path in its envirnoment variables to php5 folder. so you need to use "/php/version/php composer" instead of "php composer"
example:
/usr/bin/local/php/7.3/php composer update
for find the path of php binary file, you can use "php --ini" command to see where is "php.ini" location. when you execute this command it tell you the ini configuration file (php.ini) path. actually in the parent of your ini file location is a direction with bin name that its your php binary file location. for example in my server output "php --ini" is:
Configuration File (php.ini) Path: /usr/local/php72/lib
Loaded Configuration File: /usr/local/php72/lib/php.ini
Scan for additional .ini files in: /usr/local/php72/lib/php.conf.d
Additional .ini files parsed: /usr/local/php72/lib/php.conf.d/10-directadmin.ini,
/usr/local/php72/lib/php.conf.d/50-webapps.ini
so is my configuration file (php.ini) path:
/usr/local/php72/lib
and my php binary file is:
/usr/local/php72/bin
and my needed command is:
/usr/local/php72/bin/php composer update
Note: please pay attention don't use "which php". because its show you the global envirnoment value of php path that in your case it has set on php 5.x so you need to call binary file from php 7.x folder. and for do it, you should follow my guide to find your php 7.x binary file path

This command worked for me in CLOUDLINUX 7.9 and cPanel v94.0.4:
/opt/cpanel/ea-php73/root/usr/bin/php /opt/cpanel/composer/bin/composer update

Click on manage on the right and update the server version.

Related

Mac M1 not able to map PHP 8.0 as a CLI Interpreter within PhpStorm

I'm trying to set up the PhpStorm CLI interpreter on my New M1 Mac Book. PHP 8.0 itself is running fine, but I cannot add it as a CLI Interpreter within PhpStorm.
// installation commands
brew install php
brew link php#8.0
// which php
/opt/homebrew/bin/php
// php -v
PHP 8.0.2 (cli) (built: Feb 4 2021 12:48:26) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.2, Copyright (c) Zend Technologies
with Zend OPcache v8.0.2, Copyright (c), by Zend Technologies
sebastian#nbch003 ~ %
// php --ini
Configuration File (php.ini) Path: /opt/homebrew/etc/php/8.0
Loaded Configuration File: /opt/homebrew/etc/php/8.0/php.ini
Scan for additional .ini files in: /opt/homebrew/etc/php/8.0/conf.d
Additional .ini files parsed: /opt/homebrew/etc/php/8.0/conf.d/error_log.ini,
/opt/homebrew/etc/php/8.0/conf.d/ext-opcache.ini,
/opt/homebrew/etc/php/8.0/conf.d/php-memory-limits.ini
Usually, within the PhpStorm CLI Interpreter Settings, I map just the Path to the Current PHP Installation, but this time, PhpStorm does not recognize the PHP 8.0 Interpreter.
Compared to my old setup, on this path, no bin folder is present to select.
Any ideas?
The "PHP Executable" path in PhpStorm is not for the configuration directory, it's for the "php" binary itself.
Running which php on your terminal should reveal the linked interpreter path.
It's probably something like /opt/homebrew/bin/php.
the php executable path is in /opt/homebrew/Cellar/php/8.1.7/bin/php

How to find the right php.ini that your Apache is using?

I'm a bit confuse on my PHP versions on my local Mac OS X.
When I ran
⚡️ ~ which php
/usr/local/php5/bin/php
⚡️ ~ php --version
PHP 7.3.8 (cli) (built: Aug 11 2019 20:50:16) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.8, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.8, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.7.2, Copyright (c) 2002-2019, by Derick Rethans
⚡️ ~
so this means my CLI version is 5 or 7.3 ?? 😵 !
When I run
php -r "echo ini_get('memory_limit').PHP_EOL;"
I got
256M
the result of that matched with my Apache PHP
See picture below
phpinfo()
I really need to update the meory_limit.
How do I find php.ini of my Apache use?
Updated
I tried to modify /usr/local/php5/lib/php.ini
and set memory_limit = 40096M ~40GB
I never see that settings take place.
Maybe you should just rename /usr/local/php5 to /usr/local/php and the confusion is gone ;)
On your phpinfo() page is a section called "Loaded Configuration File" and "Additional .ini files parsed". These are the files to edit.
I am not sure if there is an upper limit for memory_limit. Maybe just try to set it to -1 to disable it.
Some php installations use different .ini files for running in a cli and running in a browser, to check what .ini files are used on command line use php --ini.

error upgrading php in mac

I am running OSX El Capitan (version 10.11.6).
I had php 5.5 installed.
Phpunit requires php5.6 and more so I tried to upgrade my php to 5.6. I couldn't do it so I gave php7 a try.
I followed these guides:
https://coolestguidesontheplanet.com/upgrade-php-on-osx/
https://php-osx.liip.ch/
Mac upgraded PHP to 5.6, but CLI php -v get 5.3.28?
My current output with php -v is :
PHP 7.0.12 (cli) (built: Nov 1 2016 10:21:11) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.12, Copyright (c) 1999-2016, by Zend Technologies
with Xdebug v2.4.1, Copyright (c) 2002-2016, by Derick Rethans
Funny thing, my output with a phpinfo(); when called from somewhere inside a Symfony project, is still PHP Version 5.5.36
Any ideas??
Terminal uses a different PHP than a HTTP server in browser. You can check what PHP you're using in CLI (command line interface) by this terminal command:
$ which php
I don't know if you use any AMP stack (like MAMP). They include their own PHP, so you need to update them in order to have a different PHP version in browser.
Maybe you can use this trick to determine what PHP versions you use in browser / CLI: Find the php.ini path in your phpinfo() output and compare it with this terminal command:
$ php -i | grep php.ini
It's always a good idea to use the debug URL to troubleshoot your Symfony projects; to use this, simply append:
app_dev.php
For example if your route was like http://myhome/, then you would use:
http://myhome/app_dev.php
Then on the bottom of your browser you will have the Symfony debug bar. In the bottom right corner, the version of Symofny is shown, an if you move your mouse over it, you will see the version of PHP; plus also a link to "View phpinfo()". You can click on it to view the full PHP information, including where the PHP file is located.
The PHP config file used (shown on the phpinfo() page) is shown by:
Loaded Configuration File
Hope that helps!

php version install issues for terminal and phpinfo()

In my terminal put that command
# php -v
i am getting
PHP 5.6.23-2+deb.sury.org~trusty+1 (cli)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
but in my localhost phpinfo();
i am getting 5.5.9
PHP Version 5.5.9-1ubuntu4.14
how can i got 5.6 in locahost phpinfo();
i am using localhost wamp server in ubundu os..
The PHP application and the Apache server will load different php.ini files,
wamp provides one in the apache directory and php itself will use the one in it's own php directory (where the apps are located)
To check that, you can do php -i | grep php.ini and compare it to the loaded Configuration File you get from your browser when using phpinfo()
To work around this issue, either install LAMP yourself, or try to link the two files together somehow.
Reference to another Stack Overflow question on the same topic

Mongo driver cannot shown in phpinfo()

# php -m | grep mongo
mongo
# php -v
PHP 5.4.7 (cli) (built: Sep 8 2013 20:19:53)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
Any idea? Thanks
PHP mongo driver version is 1.2.12
You can follow the steps in the below link
Installing Mongi Driver for PHP
Also Looks like you are having trouble in loading the driver by adding the line
extension=mongo.so
to php configuration
To do that you need to first locate your php.ini files , normally there will be two files one for command line and one for apache .
Off course you can find it in phpinfo() . If you could not find it then
To know the locations of php configuration
Just run below command
php --ini
This command lists all configuration files which are some times not visible in phpinfo()
Hope this helps
NOTE : - I assume that you are using Linux or Unix environment and not windows . I did this guess by looking at the grep command which you have posted in your code :)

Categories