Help us understand the problem. What is going on with this article?

UbuntuにPHP7の環境をつくる

More than 1 year has passed since last update.

お仕事でLaravelを使いそうなので、しれっとPHPの環境を整備したときの作業メモ。

リポジトリ追加

$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt update

php7.2とお友達をインストール

sudo apt install php7.2 php7.2-common php7.2-cli php7.2-fpm php7.2-mysql php7.2-dev php7.2-mbstring php7.2-zip

xdebugをインストールして設定

$ sudo apt-get install php-xdebug
$ sudo vim /etc/php/7.2/cli/php.ini

php.iniの最後に↓を追記
zend_extension = "/usr/lib/php/20151012/xdebug.so"
xdebug.remote_enable=on

ちょっと確認。

$ php -v
Cannot load Xdebug - it was already loaded
PHP 7.2.3-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Mar  6 2018 11:18:25) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.3-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
    with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
Cannot load Xdebug - it was already loaded

ん? なんかいた。

/etc/php/7.2/mods-available/xdebug.ini

でもxdebug.so呼んでた。
なのでコメントアウト。

composerインストール

$ curl -sS https://getcomposer.org/installer | php
$ sudo mv composer.phar /usr/local/bin/composer
$ sudo chmod +x /usr/local/bin/composer

これも確認。

$ composer -v
PHP:  syntax error, unexpected $end, expecting TC_DOLLAR_CURLY or TC_QUOTED_STRING or '"' in /etc/php/7.2/cli/php.ini on line 1917
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 1.6.3 2018-01-31 16:28:17

おk。
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away