10
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Composerのインストール

Last updated at Posted at 2019-02-05

毎回忘れるのでいい加減メモる。

環境:
AmazonLinux2
PHPインスコ済

まずセットアッパーのダウンロード
これは後で削除するのでどこでDLしてもおk

[root@ip-XX-XX-XX-XX kara-age]# php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

セットアップ実行

[root@ip-XX-XX-XX-XX kara-age]# php composer-setup.php
All settings correct for using Composer
Downloading...

Composer (version 1.8.3) successfully installed to: /home/kara-age/composer.phar

セットアップが終わったらsetup.phpを削除

rm composer-setup.php

グローバルで使えるようにする

mv composer.phar /usr/local/bin/composer

セットアップ出来たかとcomposerコマンドで実行できるか確認

[root@ip-XX-XX-XX-XX kara-age]# composer
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 1.8.3 2019-01-30 08:31:33

ちなみにrootでcomposerコマンド使ってパッケージをインストールするのはセキュリティ上良くないらしい。

How do I install untrusted packages safely? Is it safe to run Composer as superuser or root?

上記リンクの内容は以下

Certain Composer commands, including exec, install, and update allow third party code to execute on your system. This is from its "plugins" and "scripts" features. Plugins and scripts have full access to the user account which runs Composer. For this reason, it is strongly advised to avoid running Composer as
super-user/root.

rootユーザで実行すると中に入ってるexecとかinstallコマンドがrootで実行されてしまうからオススメしないよ!って話のようだ。

それらを防止するためにcomposer内の無関係なスクリプトを無効にする処理を入れておけばよいそうな。

composer install --no-plugins --no-scripts ...
composer update --no-plugins --no-scripts ...

おわり。

10
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?