22
26

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.

PHP5系からPHP7に移行した。(Homebrew

Posted at

PHP7 casualTalks#1の始まる前にざっとやって、
LT一本目まで入ってしまったけど取り合えず入れれたのでやったこと。
(PHP7の勉強会出てるのにPHP7入れてないってどういうこと?と思ったので)

概要

  • Homebrew
  • Yosemite
  • 以前まではphp5.5を入れてたっぽい?初心者のころに買ったmacだからよくわからぬ

入れようとする

$ brew update
$ brew install homebrew/php/php70
$ brew install homebrew/php/php70
==> Tapping homebrew/php
Cloning into '/usr/local/Library/Taps/homebrew/homebrew-php'...
remote: Counting objects: 575, done.
remote: Compressing objects: 100% (354/354), done.
remote: Total 575 (delta 384), reused 250 (delta 220), pack-reused 0
Receiving objects: 100% (575/575), 238.43 KiB | 347 KiB/s, done.
Resolving deltas: 100% (384/384), done.
Tapped 555 formulae (591 files, 1M)
==> Installing php70 from homebrew/php
Error: Formulae found in multiple taps:
 * homebrew/php/php53
 * josegonzalez/php/php53

Please use the fully-qualified name e.g. homebrew/php/php53 to refer the formula.

エラー。

調べたらuntapしろと。
https://github.com/Homebrew/homebrew-php/issues/1775

brew untap josegonzalez/php
brew tap --repair
brew update
 brew install homebrew/php/php70
==> Installing php70 from homebrew/php
Error: Cannot install homebrew/php/php70 because conflicting formulae are installed.

  php55: because different php versions install the same binaries.

Please `brew unlink php55` before continuing.

Unlinking removes a formula's symlinks from /usr/local. You can
link the formula again after the install finishes. You can --force this
install, but the build may fail or cause obscure side-effects in the
resulting software.

またもやエラー。
php55を外す

$ brew unlink php55
Unlinking /usr/local/Cellar/php55/5.5.22... Error: Permission denied - /usr/local/lib/php/.channels

うっ。エラー出た。。。
今回はunlinkだったからsudoで対応

$ sudo brew unlink php55

おし、行けた。

インストールしよう。

$ brew install homebrew/php/php70
==> Installing php70 from homebrew/php
==> Installing dependencies for homebrew/php/php70: libpng, freetype, get
==> Installing homebrew/php/php70 dependency: libpng
==> Downloading https://homebrew.bintray.com/bottles/libpng-1.6.21.yosemite.bott
######################################################################## 100.0%
==> Pouring libpng-1.6.21.yosemite.bottle.tar.gz
🍺  /usr/local/Cellar/libpng/1.6.21: 17 files, 1.2M
==> Installing homebrew/php/php70 dependency: freetype
==> Downloading https://homebrew.bintray.com/bottles/freetype-2.6.2.yosemite.bot
######################################################################## 100.0%
==> Pouring freetype-2.6.2.yosemite.bottle.tar.gz
🍺  /usr/local/Cellar/freetype/2.6.2: 60 files, 2.4M
==> Installing homebrew/php/php70 dependency: gettext
==> Downloading https://homebrew.bintray.com/bottles/gettext-0.19.7.yosemite.bot
######################################################################## 100.0%
==> Pouring gettext-0.19.7.yosemite.bottle.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local.

OS X provides the BSD gettext library and some software gets confused if both are in the library path.

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/gettext/lib
    CPPFLAGS: -I/usr/local/opt/gettext/include

==> Summary
🍺  /usr/local/Cellar/gettext/0.19.7: 1,929 files, 16.6M
==> Installing homebrew/php/php70 dependency: icu4c
==> Downloading https://homebrew.bintray.com/bottles/icu4c-56.1.yosemite.bottle.
######################################################################## 100.0%
==> Pouring icu4c-56.1.yosemite.bottle.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local.

OS X provides libicucore.dylib (but nothing else).

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/icu4c/lib
    CPPFLAGS: -I/usr/local/opt/icu4c/include

==> Summary
🍺  /usr/local/Cellar/icu4c/56.1: 244 files, 63.7M
==> Installing homebrew/php/php70 dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2f.yosemite.bot
######################################################################## 100.0%
==> Pouring openssl-1.0.2f.yosemite.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl/certs

and run
  /usr/local/opt/openssl/bin/c_rehash

This formula is keg-only, which means it was not symlinked into /usr/local.

Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include

==> Summary
🍺  /usr/local/Cellar/openssl/1.0.2f: 466 files, 11.9M
==> Installing homebrew/php/php70
==> Downloading https://homebrew.bintray.com/bottles-php/php70-7.0.2.yosemite.bo
######################################################################## 100.0%
==> Pouring php70-7.0.2.yosemite.bottle.10.tar.gz
==> Caveats
To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php7_module    /usr/local/opt/php70/libexec/apache2/libphp7.so

    <FilesMatch .php$>
        SetHandler application/x-httpd-php
    </FilesMatch>

Finally, check DirectoryIndex includes index.php
    DirectoryIndex index.php index.html

The php.ini file can be found in:
    /usr/local/etc/php/7.0/php.ini

✩✩✩✩ Extensions ✩✩✩✩

If you are having issues with custom extension compiling, ensure that
you are using the brew version, by placing /usr/local/bin before /usr/sbin in your PATH:

      PATH="/usr/local/bin:$PATH"

PHP70 Extensions will always be compiled against this PHP. Please install them
using --without-homebrew-php to enable compiling against system PHP.

✩✩✩✩ PHP CLI ✩✩✩✩

If you wish to swap the PHP you use on the command line, you should add the following to ~/.bashrc,
~/.zshrc, ~/.profile or your shell's equivalent configuration file:

      export PATH="$(brew --prefix homebrew/php/php70)/bin:$PATH"

✩✩✩✩ FPM ✩✩✩✩

To launch php-fpm on startup:
    mkdir -p ~/Library/LaunchAgents
    cp /usr/local/opt/php70/homebrew.mxcl.php70.plist ~/Library/LaunchAgents/
    launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php70.plist

The control script is located at /usr/local/opt/php70/sbin/php70-fpm

OS X 10.8 and newer come with php-fpm pre-installed, to ensure you are using the brew version you need to make sure /usr/local/sbin is before /usr/sbin in your PATH:

  PATH="/usr/local/sbin:$PATH"

You may also need to edit the plist to use the correct "UserName".

Please note that the plist was called 'homebrew-php.josegonzalez.php70.plist' in old versions
of this formula.

To have launchd start homebrew/php/php70 at login:
  ln -sfv /usr/local/opt/php70/*.plist ~/Library/LaunchAgents
Then to load homebrew/php/php70 now:
  launchctl load ~/Library/LaunchAgents/homebrew.mxcl.php70.plist
==> Summary
🍺  /usr/local/Cellar/php70/7.0.2: 331 files, 49.3M

出来たっぽいぞー?

$ php -v
PHP 7.0.2 (cli) (built: Jan  7 2016 10:40:21) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies

あとはbashrcにパスを通したほうが良い模様なので通す。

export PATH="$(brew --prefix homebrew/php/php70)/bin:$PATH"

これで良さそうだ。何か問題が起きたら再度考える。

22
26
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
22
26

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?