php composer update command and status: 404 Not Found on Linux

Today I tried to update Cakephp by running php composer update on my server. I tried to follow the commands given at https://getcomposer.org/download/ under Command-line installation but it failed at the very first go. The command line code was:

My server is a CentOS Linux release 7.4.1708 (Core) server with cpanel installed. So, running the first command over there gave me the following error:

Which clearly indicates the there is no r argument. If we check the above code in detail this is what it tries to do:

  1. It tries to read the installer from give url https://getcomposer.org/installer and write it to a file named composer-setup.php
  2. If the file hash matches the given hash it tells user that install is verified otherwise it says that the Installer is corrupt and deletes the file from server.
  3. Runs composer-setup.php
  4. Deletes composer-setup.php from server.

After doing all these steps it would let you run the following command in your directory in which you installed the composer:

However my method failed. After doing some searching, I found that composer was already installed on my server at location /opt/cpanel/composer/bin. Since it was installed globally and not under php, php composer won’t work at all.

php composer update

Now if I ran composer update, because it was installed in the given path it would show me the following message:

So all I needed was to specify the correct path of my working directory. Doing this worked like a charm for me:

composer update --working-dir /home/myproject/public_html/

Leave a Reply

Your email address will not be published. Required fields are marked *