• 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.

Resolved Composer set up to install Drupal and add Modules with Dependencies

PeterK900

Basic Pleskian
Server operating system version
Centos 7
Plesk version and microupdate number
Plesk Obsidian v18.0.49_build1800221221.11 os_CentOS 7
I want to be able to run commands like:
composer create-project drupal/recommended-project:9.3.12 my_site_name_dir (for a new instance of Drupal 9)
composer require drupal/module_name
(to install a Drupal module)

All looks good when I open the Plesk PHP Composer tab. I see Package Dependencies including Symphony, which D9 uses. Opening composer.json shows D9 core components. But when I open PuTTY and navigate to the folder to install Drupal, I get a PHP version error saying 5.4.16 is being used. But Plesk shows the PHP version for the domain as 7.4.33. The attached file shows some screenshots.

I haven't made any changes to the Environment Variables or the composer.json. And I assume that I have to use command line rather than the Plesk UI.

I sense I'm missing something simple, hopefully someone can point out what. I've never used composer before. Thanks.
 

Attachments

  • PleskForum_02012023a.pdf
    147.1 KB · Views: 3
Thanks for your quick reply.

I followed your link...

[root@147 /]# find /opt/plesk/php/*/bin/php
/opt/plesk/php/7.3/bin/php
/opt/plesk/php/7.4/bin/php


These are the same PHP versions I see when viewed in the Plesk UI. No sign of PHP 5.4.16

Can you help with where to look next?
 
These are the same PHP versions I see when viewed in the Plesk UI. No sign of PHP 5.4.16
The PHP 5.4 version is the native PHP version that ships with your OS. By default when you execute any PHP script via command line the default OS version is used.

The last section of the support article Peter linked to explains how you can use another PHP version, thats installed on your server by Plesk, for the command line. (And thus composer). So if you want (need) to run composer with a different PHP version follow the steps in the linked article to set a different PHP version for command line.
 
Thanks for the explanation?
How do I know if the server is chrooted or not. The non-chrooted procedure looks simpler than the other option!
 
It's up to you to chose if like to use a chrooted or non-chrooted environment. It's what you select in the second step of the article.

If you are not familiar with Chroot, it's pretty well explained in this article:

However, if you just want get you Drupal project running, and only need to run composer once or twice, this support article might be more helpful to you. Note that you'll need to install the Plesk composer extension for this.

 
Thanks for more help to understand what I'm doing. I'm very grateful.

Before I read your post, I followed the non-chrooted procedure...

[root@147 /]# su root
[root@147 /]# echo "alias php='/opt/plesk/php/7.4/bin/php'" >> ~/.bashrc
[root@147 /]# echo "if [ -f ~/.bashrc ]; then" >> ~/.bash_profile
[root@147 /]# echo ". ~/.bashrc" >> ~/.bash_profile
[root@147 /]# echo "fi" >> ~/.bash_profile
[root@147 /]# exit
exit
[root@147 /]# su root
[root@147 /]# php -v
PHP 7.4.33 (cli) (built: Nov 9 2022 08:01:02) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with the ionCube PHP Loader + ionCube24 v11.0.1, Copyright (c) 2002-2022, by ionCube Ltd.
with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies

All looked good. It now looks as though the operating system default PHP is 7.4.

But when I repeat the steps to install a Drupal instance, I still get the same PHP version error...

[root@147 /]# cd /var/www/vhosts/endhills.org/httpdocs
[root@147 httpdocs]# cd dev990
[root@147 dev990]# composer create-project drupal/recommended-project:9.3.12 dev990
Composer 2.3.0 dropped support for PHP <7.2.5 and you are running 5.4.16, please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.

I'm now off to read your posts. And yes, all I want to do is build/maintain Drupal sites. But I would like to know what went wrong if the procedure I followed. Should I have restarted the server?
Thanks again for all your help so far.
 
I've looked at both articles. Thanks. As I've not set up chrooting, I presume I was right to use the non-chrooted procedure.

I've already got the PHP composer extension installed! (See the attachment on my first post.) Does this mean I can do what I want to do without using command line? If so, can you point me to a document that shows how? What I mean is, how to set up environment variables and edit the composer.json file ( which already has Drupal components).
 
Not completely sure why composer still uses the vendors (os) PHP version (5.4) and not version 7.4 you've set. I suspect that the global composer configuration is still using the vendors (OS) PHP version. I start to think we've might have steered you in the wrong direction (or at least a more complicated direction). Sorry about that.

I recommend following this article if you want to proceed using command line. You might be able to use the PHP composer extension to accomplish the same thing from within Plesk.

I cannot open PDF attachments, so I am not sure what information you've included in it.
 
Last edited:
No apology needed. All part of my learning curve!

The last article gave me the command string that worked. Here it is...

[root@147 dev990]# /opt/plesk/php/7.4/bin/php /usr/lib64/plesk-9.0/composer.phar create-project drupal/recommended-project:9.3.12 dev990

It installed Drupal 9.3.12 in the site.com/dev990/990/web folder. Which isn't exactly what I wanted, but that's not Plesk's fault.

I realise why I got the extra subfolder, I was already in dev990, so didn't need that as an argument! Less sure about how to get rid of the web folder, but this is a question for the Drupal community. What's brilliant is that I can now install ( and hopefully add modules to ) Drupal via Composer, which means dependencies will be sorted.

Thanks Kaspar and Peter for first class support. All the best for 2023!
 
@PeterK900 glad to read you've succeeded. I do want to give you a word of caution, as I noticed that you've ran the command as a Root user. Which will cause all installed files from the packages to be owned by the Root user. Which is a severe security risk!

To prevent any security issue it's recommended to run command with the system user that is associated with the domain you're installing the packages in.
 
Last edited:
@PeterK900 glad to read you've succeeded. I do want to give you a word of caution, as I noticed that you've ran the command as a Root user. Which will cause all installed files from the packages to be owned by the Root user. Which is a severe security risk!

To prevent any security issue it's recommended to run command with the system user that is associated with the domain you're installing the packages in.
Thanks Kaspar. Only just noticed your advice!
 
Back
Top