• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Question Using Composer Upgrading Drupal Site finding old Apache Version

TomP

Basic Pleskian
I've had a similar problem to this before. Apache on my Ubuntu server running Plesk is still using PHP 7.4.3 (cli). The Drupal sites are using 8.1.12. When I try to install some of the modules that require 8.1 or greater are not installing using composer because the module is seeing the 7.4.3 version and saying it's not compatible.
I'm guessing we can't upgrade PHP without breaking either Plesk or the license?
Is there any hope PHP will upgrade someday?
 
And use the Composer.
Thank you. I gave it a try by creating a .bash_profile file in the site's root directory:
export PATH=/opt/plesk/php/8.1/bin:$PATH
alias composer='/opt/plesk/php/8.1/bin/php /usr/lib64/plesk-9.0/composer.phar'
cd siteroot
'siteroot' being the actual root of my Drupal site. I logged out and back in again and composer diagnose shows:
Checking composer version: OK
Composer version: 2.4.4
PHP version: 7.4.3
PHP binary path: /usr/bin/php7.4
 
Now I've removed the .bash_profile since things seem to be getting worse.

when I run drush updatedb I get this:

[warning] Your PHP installation is too old. Drupal requires at least PHP /8.0/. It is
recommended to upgrade to PHP version /8.0/ or higher for the best ongoing
support. See PHP's version support documentation [1] and the Drupal PHP
requirements [2] page for more information.

[1] PHP: Supported Versions
[2] PHP requirements
(Currently using PHP 7.4.3
)
 
Which OS are you using?

The above PHP paths are for CentOS 7

Please run,

/opt/plesk/php/8.1/bin/php -v

and see if the PHP path are correct.
 
I tried this and it seems to be working for me.

Code:
-bash-4.2$ composer create-project drupal/recommended-project httpdocs
Creating a "drupal/recommended-project" project at "./httpdocs"
Info from https://repo.packagist.org: #StandWithUkraine
Installing drupal/recommended-project (9.4.8)
  - Installing drupal/recommended-project (9.4.8): Extracting archive
Created project in /var/www/vhosts/dawholesale.xyz/httpdocs
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Package operations: 62 installs, 0 updates, 0 removals

-bash-4.2$ composer require drush/drush
Using version ^11.3 for drush/drush
./composer.json has been updated
Running composer update drush/drush
Loading composer repositories with package information
Updating dependencies
Lock file operations: 22 installs, 0 updates, 0 removals

-bash-4.2$ ./vendor/bin/drush --version
Drush Commandline Tool 11.3.2

-bash-4.2$ ./vendor/bin/drush site:install

 Database name [drupal]:
 >
 
My current .bash_profile is,

Code:
export PATH=/opt/plesk/php/8.1/bin:$PATH
export PATH=./vendor/bin:$PATH
alias composer='/opt/plesk/php/8.1/bin/php /usr/lib64/plesk-9.0/composer.phar'
cd httpdocs

Please note the,
export PATH=./vendor/bin:$PATH for drush to run without the ./vendor/bin/

If you make changes to .bash_profile you have to reload it or logout and login again.

$. ~/.bash_profile

Code:
-bash-4.2$ drush site:install

 Database name [drupal]:
 > xxxxx

 Database driver [mysql]:
 >

 Database username [drupal]:
 > xxxxxx

 Database password [drupal]:
 > xxxxxxx

 Database host [127.0.0.1]:
 >

 Database port [3306]:
 >


 You are about to:
 * Create a sites/default/settings.php file
 * DROP all tables in your 'drupaldb' database.

 Do you want to continue? (yes/no) [yes]:
 > yes

 [notice] Starting Drupal installation. This takes a while.
 [notice] Performed install task: install_select_language
 [notice] Performed install task: install_select_profile
 [notice] Performed install task: install_load_profile
 [notice] Performed install task: install_verify_requirements
 [notice] Performed install task: install_settings_form
 [notice] Performed install task: install_verify_database_ready
 [notice] Performed install task: install_base_system
 [notice] Performed install task: install_bootstrap_full
 [notice] Performed install task: install_profile_modules
 [notice] Performed install task: install_profile_themes
 [notice] Performed install task: install_install_profile
 [notice] Performed install task: install_configure_form
 [notice] Performed install task: install_finished
 [success] Installation complete.  User name: admin  User password: xxxxxxx

I'm a Magento 2 Developer. I have no experience in Drupal. But hope this will you.
 
Which OS are you using?

The above PHP paths are for CentOS 7

Please run,

/opt/plesk/php/8.1/bin/php -v

and see if the PHP path are correct.
Sorry I can't do much right now because I'm on just my phone till tomorrow. I'm using Ubuntu on the server updated to the latest through Plesk updates. I'll check more in the morning. Thanks
 
I am using Plesk ver 18.0.48. Ubuntu 20.04.5 LTS. All the sites are set to run PHP 8.1.12 through their subscription on Plesk.

When I run '/opt/plesk/php/8.1/bin/php -v' I get this:
Code:
# /opt/plesk/php/8.1/bin/php -v
PHP 8.1.13 (cli) (built: Nov 28 2022 06:40:38) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.13, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.13, Copyright (c), by Zend Technologies
I get the same if I'm logged in as root or the site owner.


I created a new .bash_profile:
Code:
export PATH=/opt/plesk/php/8.1/bin:$PATH
export PATH=./vendor/bin:$PATH
alias composer='/opt/plesk/php/8.1/bin/php /usr/lib/plesk-9.0/composer.phar'
I changed the lib64 to lib after checking where mine was. Then logged out and back in and tried 'php -v"
Code:
PHP 7.4.3 (cli) (built: Nov  2 2022 09:53:44) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with the ionCube PHP Loader + ionCube24 v10.4.5, Copyright (c) 2002-2020, by ionCube Ltd.
    with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
and 'composer diagnose' gives this:
Code:
composer diagnose
Checking platform settings: OK
Checking git settings: OK git version 2.25.1
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com oauth access: OK
Checking disk free space: OK
Checking composer version: OK
Composer version: 2.4.4
PHP version: 7.4.3
PHP binary path: /usr/bin/php7.4
OpenSSL version: OpenSSL 1.1.1f  31 Mar 2020
cURL version: 7.68.0 libz 1.2.11 ssl OpenSSL/1.1.1f
zip: extension present, unzip present, 7-Zip not available
I even tried to run '~/.bash_profile' while logged in as the site owner, just to be sure there were no errors running it.
 
I think I solved it, but I'm not sure if this will keep working.
When I run 'which php' I get: /usr/bin/php so I followed it.

/usr/bin/php is a symlink to /etc/alternatives/php.
/etc/alternatives/php is in turn a symlink to /usr/bin/php7.4, which is the php file for version 7.4.
I went to /opt/plesk/php/8.1/bin/php and copied the php file there to /usr/bin/ naming it php8.1.
I changed /etc/alternatives/php to point to /usr/bin/php8.1 instead of php7.4.

I logged back in and php -v now says php 8.1.13. Logging in as site admins and running all the commands shows no errors, and even Composer shows using PHP 8.1.13.
The Plesk interface is working and no errors are showing. I don't know when any updates come down if the updater won't like the change so I'll have to see.
According to the Ubuntu main site, it does run on PHP 8.1, but the default is still 7.4 and it doesn't sound like there are plans to change it. I just hope this works for now.
 
I tried this on a server,

OS - Ubuntu 20.04.5 LTS
Product - Plesk Obsidian Version 18.0.48, last updated on Dec 6, 2022 12:56 AM

When you changed the PHP version via the Panel, It changes the CLI PHP version as well.

Code:
webhostingace@flamboyant-mcclintock:~$ which php
/var/www/vhosts/domain.tld/.phpenv/shims/php
webhostingace@flamboyant-mcclintock:~$ echo $PATH
/var/www/vhosts/domain.tld/.phpenv/shims:/opt/plesk/phpenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
webhostingace@flamboyant-mcclintock:~$
 
I tried this on a server,

OS - Ubuntu 20.04.5 LTS
Product - Plesk Obsidian Version 18.0.48, last updated on Dec 6, 2022 12:56 AM

When you changed the PHP version via the Panel, It changes the CLI PHP version as well.

Code:
webhostingace@flamboyant-mcclintock:~$ which php
/var/www/vhosts/domain.tld/.phpenv/shims/php
webhostingace@flamboyant-mcclintock:~$ echo $PATH
/var/www/vhosts/domain.tld/.phpenv/shims:/opt/plesk/phpenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
webhostingace@flamboyant-mcclintock:~$
All the sites are set separately to run the latest PHP. When I was logging in SSH as one of the site admins or even root, it was always showing 7.4.
 
All the sites are set separately to run the latest PHP. When I was logging in SSH as one of the site admins or even root, it was always showing 7.4.
You'll get the operating system's PHP version when you log in to a shell. That is the correct and expected behavior.
 
You'll get the operating system's PHP version when you log in to a shell. That is the correct and expected behavior.
That is the problem. There doesn't seem to be an easy way to set the "shell" version. Most of my systems that run at the command prompt level. like Drush, and Composer, all warn that they will no longer work soon unless PHP shows at least 8.X . The trick I did as I said above does seem to be working without any problems so far. I don't know what's going to happen one Plesk does a big Apache or Ubuntu update.
 
There is an official workaround, maybe it is helpful for you?
I actually tried that once and it didn't work. I tried it twice with the same results, but maybe I did something wrong. I don't know what it could have been though because the directions are pretty straight forward.
 
Back
Top