読者です 読者をやめる 読者になる 読者になる

php install

イシュー

  • php をインストールする

参考

brew install composer すると入るコンポーネント

MagsBook:~ magnet$ ls -trl /usr/local/Cellar/
total 0
drwxr-xr-x  3 magnet  admin  102 10 30 00:42 nodebrew
drwxr-xr-x  3 magnet  admin  102 11  1 00:24 libpng
drwxr-xr-x  3 magnet  admin  102 11  1 00:24 gettext
drwxr-xr-x  3 magnet  admin  102 11  1 00:24 freetype
drwxr-xr-x  3 magnet  admin  102 11  1 00:24 icu4c
drwxr-xr-x  3 magnet  admin  102 11  1 00:24 jpeg
drwxr-xr-x  3 magnet  admin  102 11  1 00:24 unixodbc
drwxr-xr-x  3 magnet  admin  102 11  1 00:24 libxml2
drwxr-xr-x  3 magnet  admin  102 11  1 00:24 readline
drwxr-xr-x  3 magnet  admin  102 11  1 00:24 openssl
drwxr-xr-x  3 magnet  admin  102 11  1 00:31 php56
drwxr-xr-x  3 magnet  admin  102 11  1 00:32 composer
MagsBook:~ magnet$ 

brew install phpbrew すると入るコンポーネント

drwxr-xr-x  3 magnet  admin  102 11  1 01:22 curl
drwxr-xr-x  3 magnet  admin  102 11  1 01:22 libevent
drwxr-xr-x  3 magnet  admin  102 11  1 01:22 gmp
drwxr-xr-x  3 magnet  admin  102 11  1 01:22 pcre
drwxr-xr-x  3 magnet  admin  102 11  1 01:22 mhash
drwxr-xr-x  3 magnet  admin  102 11  1 01:22 mcrypt
drwxr-xr-x  3 magnet  admin  102 11  1 01:22 re2c
drwxr-xr-x  3 magnet  admin  102 11  1 01:22 phpbrew

注: phpbrew で phpをインストールしようとするとエラー

MagsBook:~ magnet$ phpbrew install 5.6.27
===> phpbrew will now build 5.6.27
You haven't set any variant. A default set of extensions will be installed for the minimum requirement:
[bcmath, bz2, calendar, cli, ctype, dom, fileinfo, filter, ipc, json, mbregex, mbstring, mhash, pcntl, pcre, pdo, phar, posix, readline, sockets, tokenizer, xml, curl, zip, openssl, opcache]
Please run 'phpbrew variants' for more information.

===> Loading and resolving variants...
Checking distribution checksum...
Checksum matched: b5a66d238c27cfdc6cdf5e83062e50d9
===> Distribution file was successfully extracted, skipping...
===> Checking patches...
Checking patch for replace apache php module name with custom version name
Found existing build.log, renaming it to /Users/magnet/.phpbrew/build/php-5.6.27/build.log.1477923846
===> Configuring 5.6.27...


Use tail command to see what's going on:
   $ tail -F /Users/magnet/.phpbrew/build/php-5.6.27/build.log


Error: Configure failed:
The last 5 lines in the log file:
checking for DSA_get_default_method in -lssl... no

checking for X509_free in -lcrypto... yes

checking for RAND_egd... no

checking for pkg-config... no

configure: error: Cannot find OpenSSL's <evp.h>

Please checkout the build log file for more details:
     tail /Users/magnet/.phpbrew/build/php-5.6.27/build.log
MagsBook:~ magnet$ 

troubleshoot

default バリアントをつけることで成功する

MagsBook:~ magnet$ phpbrew install php-5.6.27 +default
===> phpbrew will now build 5.6.27
===> Loading and resolving variants...
Downloading http://www.php.net/get/php-5.6.27.tar.bz2/from/this/mirror via curl extension
Redirecting to http://jp2.php.net/distributions/php-5.6.27.tar.bz2
[==================================================================] 14.28/14.28MB 100%
===> Extracting /Users/magnet/.phpbrew/distfiles/php-5.6.27.tar.bz2 to /Users/magnet/.phpbrew/build/tmp.1478009570/php-5.6.27
===> Moving /Users/magnet/.phpbrew/build/tmp.1478009570/php-5.6.27 to /Users/magnet/.phpbrew/build/php-5.6.27
===> Checking patches...
Checking patch for replace apache php module name with custom version name
===> Configuring 5.6.27...


Use tail command to see what's going on:
   $ tail -F /Users/magnet/.phpbrew/build/php-5.6.27/build.log


===> Checking patches...
Checking patch for php5.3.29 multi-sapi patch.
Checking patch for php5.3.x on 64bit machine when intl is enabled.
Checking patch for openssl dso linking patch
3 changes patched.
===> Building...
Build finished: 7.9 minutes.
Installing...
---> Creating php-fpm.conf
---> Creating php.ini
---> Copying /Users/magnet/.phpbrew/build/php-5.6.27/php.ini-development 
---> Found date.timezone is not set, patching...
---> Found date.timezone, patching config timezone with Asia/Tokyo
Congratulations! Now you have PHP with 5.6.27 as php-5.6.27

* To configure your installed PHP further, you can edit the config file at
    /Users/magnet/.phpbrew/php/php-5.6.27/etc/php.ini

* WARNING:
  You haven't setup your .bashrc file to load phpbrew shell script yet!
  Please run 'phpbrew init' to see the steps!

To use the newly built PHP, try the line(s) below:

    $ phpbrew use php-5.6.27

Or you can use switch command to switch your default php to php-5.6.27:

    $ phpbrew switch php-5.6.27

Enjoy!
MagsBook:~ magnet$ 
MagsBook:Temp magnet$ phpbrew use php-5.6.27
You should not see this, if you see this, it means you didn't load the ~/.phpbrew/bashrc script, please check if bashrc is sourced in your shell.
MagsBook:Temp magnet$

troubleshoot

OSX では.bashrc ではなく、.bash_profileに記述すると動く

.[bash_]profile and .bashrc can be used on both OS X and Linux. The former is loaded when the shell is a login shell; the latter when it is not. The real difference is that Linux runs a login shell when the user logs into a graphical session, and then, when you open a terminal application, those shells are non-login shells; whereas OS X does not run a shell upon graphical login, and when you run a shell from Terminal.app, that is a login shell. [ -r ~/.bashrc ] && source ~/.bashrc

.[bash_]profile と .bashrcは、OS XLinuxの両方で使用することができます。

シェルがログインシェルである場合に前者がロードされます。後者はそうではない場合にロードされます。

本当の違いは、Linuxを使用すると、ターミナルアプリケーションを開いたときに、ユーザのグラフィカルセッションにログイン、および、それらのシェルは非ログインシェルであるログインシェルを実行するということです。

一方、OS Xは、グラフィカルログイン時にシェルを実行していない、とあなたはTerminal.appからシェルを実行すると、それがログインシェルです。

あなたのエイリアスが両方のログインと非ログインシェルで仕事をしたい(とあなたが通常行う)場合は、このような行で、あなたの.bash_profileにbashrcに、ソースの.bashrcに入れてください。

[ -r ~/.bashrc ] && source ~/.bashrc