LoginSignup
0
0

Xserver共有レンタルサーバのSSHで好きなバージョンのPHPを使う

Posted at

せこい貧乏人なので、相変わらず共有サーバを使ってます

Xserverの共有レンタルサーバはドメインごとにPHPのバージョンを設定できるが、SSHでログインした場合、デフォルトで5系の最新が動くように設定されており、色々と困る。

$ composer upgrade
Loading composer repositories with package information
Warning from https://repo.packagist.org: Support for Composer 1 is deprecated and some packages will not be available. You should upgrade to Composer 2. See https://blog.packagist.com/deprecating-composer-1-support/
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - twig/twig v2.9.0 requires php ^7.0 -> your PHP version (5.4.16) does not satisfy that requirement.
    - twig/twig v2.8.1 requires php ^7.0 -> your PHP version (5.4.16) does not satisfy that requirement.
    - twig/twig v2.8.0 requires php ^7.0 -> your PHP version (5.4.16) does not satisfy that requirement.
    - twig/twig v2.7.4 requires php ^7.0 -> your PHP version (5.4.16) does not satisfy that requirement.

今までずっと良くわかってなくて詰んでたんだけど

$ ps ux
USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
himitsu+ 122225  0.0  0.0  72336  4692 ?        Ss   19:35   0:00 /usr/libexec/openssh/sftp-server
himitsu+ 214016  0.0  0.0 115748  3832 pts/0    Ss   19:43   0:00 -bash
himitsu+ 290866  0.0  0.0 525952 87192 ?        S    19:58   0:02 /usr/bin/php-fcgi7.0

なんか /usr/bin/php-fcgi7.0 とかいうやつがあるな

$ php-fcgi7.0 composer.phar
X-Powered-By: PHP/7.0.33
Content-type: text/html; charset=UTF-8
Warning: Composer should be invoked via the CLI version of PHP, not the cgi-fcgi SAPI

なんかおこられた

$ find /usr/bin/php*
/usr/bin/php
/usr/bin/php-cgi
/usr/bin/php-fcgi4.4
/usr/bin/php-fcgi5.1
/usr/bin/php-fcgi5.2
/usr/bin/php-fcgi5.3
/usr/bin/php-fcgi5.4
/usr/bin/php-fcgi5.5
/usr/bin/php-fcgi5.6
/usr/bin/php-fcgi7.0
/usr/bin/php-fcgi7.1
/usr/bin/php-fcgi7.2
/usr/bin/php-fcgi7.3
/usr/bin/php-fcgi7.4
/usr/bin/php-fcgi8.0
/usr/bin/php-fcgi8.1
/usr/bin/php-fcgi8.2
/usr/bin/php4.4
/usr/bin/php5.1
/usr/bin/php5.2
/usr/bin/php5.3
/usr/bin/php5.4
/usr/bin/php5.5
/usr/bin/php5.6
/usr/bin/php5.6-cgi
/usr/bin/php7.0
/usr/bin/php7.0-cgi
/usr/bin/php7.1
/usr/bin/php7.1-cgi
/usr/bin/php7.2
/usr/bin/php7.2-cgi
/usr/bin/php7.3
/usr/bin/php7.3-cgi
/usr/bin/php7.4
/usr/bin/php7.4-cgi
/usr/bin/php8.0
/usr/bin/php8.0-cgi
/usr/bin/php8.1
/usr/bin/php8.1-cgi
/usr/bin/php8.2
/usr/bin/php8.2-cgi
/usr/bin/phpize

なんや、揃ってるやん

$ php7.4 composer.phar
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 1.6.2 2018-01-05 15:28:41
0
0
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
0
0