{"id":9322,"date":"2021-06-25T00:49:04","date_gmt":"2021-06-24T21:49:04","guid":{"rendered":"https:\/\/kifarunix.com\/?p=9322"},"modified":"2024-03-18T20:16:26","modified_gmt":"2024-03-18T17:16:26","slug":"install-php-composer-on-rocky-linux-8","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-php-composer-on-rocky-linux-8\/","title":{"rendered":"Install PHP Composer on Rocky Linux 8"},"content":{"rendered":"\n

Want to use PHP composer on Rocky Linux 8? Well, this tutorial provides a step-by-step guide on how to install PHP composer on Rocky Linux 8. Follow through to learn how to. “Composer<\/a> is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install\/update) them for you”.<\/em><\/p>\n\n\n\n

Installing PHP Composer on Rocky Linux 8<\/h2>\n\n\n\n

Prerequisites<\/h3>\n\n\n\n

Composer requires PHP 5.3.2+ to run.<\/p>\n\n\n\n

We are using PHP 7.4 in this guide.<\/p>\n\n\n\n

php -v<\/code><\/pre>\n\n\n\n
PHP 7.4.6 (cli) (built: May 12 2020 08:09:15) ( NTS )\nCopyright (c) The PHP Group\nZend Engine v3.4.0, Copyright (c) Zend Technologies\n    with Zend OPcache v7.4.6, Copyright (c), by Zend Technologies<\/code><\/pre>\n\n\n\n

You can check how to install PHP on rocky Linux by following the link below;<\/p>\n\n\n\n

Install PHP on Rocky Linux 8<\/a><\/p>\n\n\n\n

There are two ways in which you can install PHP composer.<\/p>\n\n\n\n

    \n
  1. Locally as part of your project<\/a><\/li>\n\n\n\n
  2. globally as a system wide executable<\/a><\/li>\n<\/ol>\n\n\n\n

    Install PHP Composer Locally for Specific Project<\/h4>\n\n\n\n

    Navigate to Program’s directory. To install PHP composer as part of your specific program, navigate to the program’s directory.<\/p>\n\n\n\n

    Download PHP Composer Installer Script. Run the command below to download PHP composer installer script;<\/p>\n\n\n\n

    php -r \"copy('https:\/\/getcomposer.org\/installer', 'composer-setup.php');\"<\/code><\/pre>\n\n\n\n

    Verify the integrity of the installer<\/p>\n\n\n\n

    To confirm that you are installing the actual composer, you need to verify the integrity of the installer script downloaded above. This can be done by downloading the hash and comparing and validating as follows<\/p>\n\n\n\n

    php -r \"if (hash_file('sha384', 'composer-setup.php') === '$(wget -qO - https:\/\/composer.github.io\/installer.sig)') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;\"<\/code><\/pre>\n\n\n\n

    If the file is file, you should see an output like Installer verified<\/code><\/strong>.<\/p>\n\n\n\n

    Install PHP Composer<\/p>\n\n\n\n

    Next, run the installer;<\/p>\n\n\n\n

    php composer-setup.php<\/code><\/pre>\n\n\n\n

    Sample command output;<\/p>\n\n\n\n

    All settings correct for using Composer\nDownloading...\n\nComposer (version 2.1.3) successfully installed to: \/home\/kifarunix\/composer.phar\nUse it: php composer.phar<\/code><\/pre>\n\n\n\n

    Remove the installer<\/p>\n\n\n\n

    Remove the installer once Composer is installed.<\/p>\n\n\n\n

    php -r \"unlink('composer-setup.php');\"<\/code><\/pre>\n\n\n\n

    Verify Composer Installation by running the command;<\/p>\n\n\n\n

    php composer.phar<\/code><\/pre>\n\n\n\n

    If you run the command above as root, you will receive a warning on the same:<\/p>\n\n\n\n

    Do not run Composer as root\/super user! See https:\/\/getcomposer.org\/root for details\nContinue as root\/super user [yes]? yes\n   ______\n  \/ ____\/___  ____ ___  ____  ____  ________  _____\n \/ \/   \/ __ \\\/ __ `__ \\\/ __ \\\/ __ \\\/ ___\/ _ \\\/ ___\/\n\/ \/___\/ \/_\/ \/ \/ \/ \/ \/ \/ \/_\/ \/ \/_\/ (__  )  __\/ \/\n\\____\/\\____\/_\/ \/_\/ \/_\/ .___\/\\____\/____\/\\___\/_\/\n                    \/_\/\nComposer version 2.1.3 2021-06-09 16:31:20\n\nUsage:\n  command [options] [arguments]\n\nOptions:\n  -h, --help                     Display this help message\n  -q, --quiet                    Do not output any message\n  -V, --version                  Display this application version\n      --ansi                     Force ANSI output\n      --no-ansi                  Disable ANSI output\n  -n, --no-interaction           Do not ask any interactive question\n      --profile                  Display timing and memory usage information\n      --no-plugins               Whether to disable plugins.\n  -d, --working-dir=WORKING-DIR  If specified, use the given directory as working directory.\n      --no-cache                 Prevent use of the cache\n  -v|vv|vvv, --verbose           Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug\n\nAvailable commands:\n  about                Shows a short information about Composer.\n  archive              Creates an archive of this composer package.\n  browse               Opens the package's repository URL or homepage in your browser.\n...\n<\/code><\/pre>\n\n\n\n

    Install PHP Composer Globally<\/h4>\n\n\n\n

    To make composer available system wide, run the commands above but while installing composer, use the command, php composer-setup.php --install-dir=\/usr\/bin --filename=composer<\/code><\/strong> instead of php composer-setup.php<\/code><\/strong>.<\/p>\n\n\n\n

    Simply execute the commands below;<\/p>\n\n\n\n

    php -r \"copy('https:\/\/getcomposer.org\/installer', 'composer-setup.php');\"<\/code><\/pre>\n\n\n\n
    php -r \"if (hash_file('sha384', 'composer-setup.php') === '$(wget -qO - https:\/\/composer.github.io\/installer.sig)') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;\"<\/code><\/pre>\n\n\n\n
    php composer-setup.php --install-dir=\/usr\/bin --filename=composer<\/code><\/pre>\n\n\n\n
    php -r \"unlink('composer-setup.php');\"<\/code><\/pre>\n\n\n\n

    Running Composer:<\/p>\n\n\n\n

    Now instead of running php composer.phar<\/strong><\/code>, use composer<\/strong><\/code>.<\/p>\n\n\n\n

    composer -V<\/code><\/pre>\n\n\n\n
    ...\nComposer version 2.1.3 2021-06-09 16:31:20<\/strong><\/code><\/pre>\n\n\n\n

    And that is how simple it is to Install PHP composer on Rocky Linux 8.<\/p>\n\n\n\n

    Other tutorials:<\/p>\n\n\n\n

    Install LAMP Stack on Rocky Linux 8<\/a><\/p>\n\n\n\n

    Install LEMP Stack on Rocky Linux 8<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"

    Want to use PHP composer on Rocky Linux 8? Well, this tutorial provides a step-by-step guide on how to install PHP composer on Rocky Linux<\/p>\n","protected":false},"author":3,"featured_media":9325,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[342,121,201,235],"tags":[3744,3746,3745,203,3743,3742],"class_list":["post-9322","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","category-howtos","category-lamp-stack","category-lemp-stack","tag-composer","tag-install-composer-rocky-linux","tag-install-php-composer-rocky-linux","tag-php","tag-php-composer","tag-php-composer-rocky-linux-8","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/9322"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=9322"}],"version-history":[{"count":5,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/9322\/revisions"}],"predecessor-version":[{"id":21763,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/9322\/revisions\/21763"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/9325"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=9322"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=9322"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=9322"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}