• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • 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 Plesk on Centos 7: composer not found

marvin

Basic Pleskian
Server operating system version
Centos 7
Plesk version and microupdate number
Onyx 18
Hi, I have this VPS running Plesk Onyx 18 and I have a number of websites on it. I'm trying to set up a new website and need to run composer. Except I can't...
Every time I try to run a composer command I get composer not found

I can see composer.phar (as Root, not user). I can generate php composer.phar (as user) and see the startup printout. I just can't do anything else with it...
I've tried from both the Plesk side and using CLI. I've checked permissions (755) -- I've even resorted to using SFTP to get my files onto the server, so now the website is somewhat 'munted' (a technical term in NZ -- look it up...)

So now I'm more than somewhat pissed off with the situation... is there anybody here that can offer advice?

p.s. Well I'm stunned to find I had this same problem two years ago when I joined Plesk Forum. Plesk Forum had no suggestions then, I fixed it (somehow) but here we go again...
 
I have just recalled how I went about accessing composer because Plesk is too dumb to know that it exists. The trick is to go in via command line (because the composer GIU feature for composer obviously doesn't work in these cases). I'll just leave this here, not only for my own person future reference, but so that any other poor sods grappling with the same issue will find it helpful...

Code:
/opt/plesk/php/8.0/bin/php /usr/lib64/plesk-9.0/composer.phar update

Code:
/opt/plesk/php/8.0/bin/php /usr/lib64/plesk-9.0/composer.phar vendor expose copy

How very depressing...

How very depressing...
 
You can create a ".bash_profile" in the Home Directory of the subscription with the content,

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

Then change the "Access to the server over SSH" to "/bin/bash"

When you login to SSH, You will have access to the both PHP and Composer.
 
Thanks for your reply @WebHostingAce . So what I would be doing here is creating an alias to Composer from within httpdocs ? And (obviously) I would need to do this each time I set up new hosting?

I'll set this up. Much easier than arcane and convoluted commands each time I want Composer to do anything!! :)
 
You have to create this file in the "Home Directory" not in the httpdocs.

If you don't want to create this file, each time you setup new hosting, You can add this to vhost template.
 
@WebHostingAce , I ran the code and all is good in CLI over SSH. I still can't use the composer interface in Plesk, but I can live with that. Thanks for your insights!
 
I just tried this in the Plesk SSH interface and it works.

I think if you create a .bash_profile (dot file) in the Home Directory(Home Directory is not httpdocs) of the subscription Then change the "Access to the server over SSH" to "/bin/bash". It will work.
 
Just getting back to this - any ideas please what is wrong here...

blberry@hardcore-gauss:~$ pwd /var/www/vhosts/example.com blberry@hardcore-gauss:~$ ls -a . .bash_history .composer httpdocs .phpenv .php-version .revisium_antivirus_cache .. .bash_profile error_docs logs .php-ini private .trash blberry@hardcore-gauss:~$ cat .bash_profile export PATH=/opt/plesk/php/7.4/bin:$PATH alias composer='/opt/plesk/php/7.4/bin/php /usr/lib64/plesk-9.0/composer.phar' cd httpdocs blberry@hardcore-gauss:~$ composer Could not open input file: /usr/lib64/plesk-9.0/composer.phar blberry@hardcore-gauss:~$ cd httpdocs blberry@hardcore-gauss:~/httpdocs$ ls composer.json composer.lock index.html blberry@hardcore-gauss:~/httpdocs$ composer Could not open input file: /usr/lib64/plesk-9.0/composer.phar blberry@hardcore-gauss:~/httpdocs$ namei -l /usr/local/psa/var/modules/composer//composer.phar f: /usr/local/psa/var/modules/composer//composer.phar drwxr-xr-x root root / drwxr-xr-x root root usr drwxr-xr-x root root local lrwxrwxrwx root root psa -> /opt/psa drwxr-xr-x root root / drwxr-xr-x root root opt drwxr-xr-x root root psa drwxr-xr-x psaadm psaadm var drwxr-xr-x psaadm root modules drwxr-xr-x psaadm psaadm composer -rwxr-xr-x root root composer.phar blberry@hardcore-gauss:~/httpdocs$
 
These paths are for CentOS 7

Please check with your OS.

Thanks I think I got it working for my Debian:

Code:
blberry@hardcore-gauss:~/httpdocs$ cat /etc/debian_version
11.4
blberry@hardcore-gauss:~/httpdocs$ find / -name "composer.phar"
/usr/lib/plesk-9.0/composer.phar
/opt/psa/var/modules/composer/composer.phar
/opt/psa/admin/plib/modules/composer/resources/composer/composer.phar
blberry@hardcore-gauss:~$ pwd
/var/www/vhosts/example.com
blberry@hardcore-gauss:~$ ls -a
.   .bash_history  .composer   httpdocs  .phpenv   .php-version  .revisium_antivirus_cache
..  .bash_profile  error_docs  logs      .php-ini  private       .trash
blberry@hardcore-gauss:~$ cat .bash_profile
export PATH=/opt/plesk/php/7.4/bin:$PATH
alias composer='/opt/plesk/php/7.4/bin/php /usr/lib/plesk-9.0/composer.phar'
cd httpdocs
blberry@hardcore-gauss:~$ composer
composer
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 2.3.10 2022-07-13 15:48:23
 
Back
Top