Home >Backend Development >PHP Tutorial >How to Install Composer on Shared Hosting Without SSH Access?

How to Install Composer on Shared Hosting Without SSH Access?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-10-18 12:31:30949browse

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.

The above is the detailed content of How to Install Composer on Shared Hosting Without SSH Access?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn