"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > How to Install Composer on Shared Hosting Without SSH Access?

How to Install Composer on Shared Hosting Without SSH Access?

Published on 2024-11-12
Browse:190

How to Install Composer on Shared Hosting Without SSH Access?

Installing Composer on Shared Hosting Without SSH Access

Installing Composer on a shared hosting platform without SSH access can be a challenge. However, it's possible with the following steps:

1. Gather Required Resources:

You'll need the following resources:

  • File: http://api.odtu.lu/composer.phar
  • PHPInfo page: http://api.odtu.lu/phpinfo.php
  • FTP access
  • cPanel
  • Cron jobs on FreeBSD

2. Download and Install Composer:

  • Use FTP or cPanel to connect to your hosting account.
  • Navigate to your home directory and create a bin directory.
  • Inside the bin directory, create a composer subdirectory.
  • Download Composer using the following command:

    curl -sS https://getcomposer.org/installer | php
  • Move the downloaded composer.phar file to the composer subdirectory:

    mv composer.phar bin/composer

3. Determine PHP-CLI Location:

  • Run the following command to locate the path to your PHP-CLI:

    which php-cli

4. Configure Aliases:

  • Edit the .bashrc file and add the following lines at the top and bottom:

    [ -z "$PS1" ] && return
    alias composer="/usr/bin/php-cli ~/bin/composer/composer.phar"
  • Replace /usr/bin/php-cli with the PHP-CLI path you determined earlier.

5. Final Steps:

  • Source the .bashrc file:

    source ~/.bashrc
  • Check if Composer is installed:

    composer --version

Note: If you encounter permission issues with /usr/local/bin, grant the necessary permissions or change the alias path to another writable directory.

Release Statement This article is reprinted at: 1729220657 If there is any infringement, please contact [email protected] to delete it
Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3