31
33

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.

UbuntuにPHP7の環境をつくる

Last updated at Posted at 2018-03-09

お仕事で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。
31
33
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
31
33

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?