windows で php をビルドしてみた
TRANSCRIPT
![Page 1: Windows で PHP をビルドしてみた](https://reader034.vdocuments.site/reader034/viewer/2022050800/587068281a28ab48378b564b/html5/thumbnails/1.jpg)
Windows でPHP をビルドしてみた
内山 雄司 (@y__uti)
2016/01/27 第98回 PHP 勉強会
![Page 2: Windows で PHP をビルドしてみた](https://reader034.vdocuments.site/reader034/viewer/2022050800/587068281a28ab48378b564b/html5/thumbnails/2.jpg)
今日の発表やってみたこと◦ Windows で PHP をビルドしてみた
わかったこと◦ Windows で PHP をビルドするのは簡単
2014/01/27 第 98 回 PHP 勉強会 2
![Page 3: Windows で PHP をビルドしてみた](https://reader034.vdocuments.site/reader034/viewer/2022050800/587068281a28ab48378b564b/html5/thumbnails/3.jpg)
Windowsでのビルド手順公式ウェブサイトに説明あり
◦ https://wiki.php.net/internals/windows/stepbystepbuild
2014/01/27 第 98 回 PHP 勉強会 3
![Page 4: Windows で PHP をビルドしてみた](https://reader034.vdocuments.site/reader034/viewer/2022050800/587068281a28ab48378b564b/html5/thumbnails/4.jpg)
PHP のビルド環境PHP のバージョンに合った Visual Studio が必要
◦ https://wiki.php.net/internals/windows/compiler
2014/01/27 第 98 回 PHP 勉強会 4
![Page 5: Windows で PHP をビルドしてみた](https://reader034.vdocuments.site/reader034/viewer/2022050800/587068281a28ab48378b564b/html5/thumbnails/5.jpg)
Visual Studio 2015Community Edition で大丈夫
◦ https://www.visualstudio.com/downloads/download-visual-studio-vs
2014/01/27 第 98 回 PHP 勉強会 5
![Page 6: Windows で PHP をビルドしてみた](https://reader034.vdocuments.site/reader034/viewer/2022050800/587068281a28ab48378b564b/html5/thumbnails/6.jpg)
VS2015のインストール「カスタム」を選択して C++ をチェック
2014/01/27 第 98 回 PHP 勉強会 6
![Page 7: Windows で PHP をビルドしてみた](https://reader034.vdocuments.site/reader034/viewer/2022050800/587068281a28ab48378b564b/html5/thumbnails/7.jpg)
ダウンロード(その1)PHP のソースコード
◦ http://windows.php.net/download/
2014/01/27 第 98 回 PHP 勉強会 7
![Page 8: Windows で PHP をビルドしてみた](https://reader034.vdocuments.site/reader034/viewer/2022050800/587068281a28ab48378b564b/html5/thumbnails/8.jpg)
ダウンロード(その2)ビルド用のツールと依存ライブラリ
◦ http://windows.php.net/downloads/php-sdk/
2014/01/27 第 98 回 PHP 勉強会 8
![Page 9: Windows で PHP をビルドしてみた](https://reader034.vdocuments.site/reader034/viewer/2022050800/587068281a28ab48378b564b/html5/thumbnails/9.jpg)
ビルド用フォルダの作成公式ウェブサイトに書いてあるとおり
◦ https://wiki.php.net/internals/windows/stepbystepbuild
◦ 詳細は省略
2014/01/27 第 98 回 PHP 勉強会 9
![Page 10: Windows で PHP をビルドしてみた](https://reader034.vdocuments.site/reader034/viewer/2022050800/587068281a28ab48378b564b/html5/thumbnails/10.jpg)
ビルド用フォルダの完成図こんな感じのフォルダ構成になれば OK
2014/01/27 第 98 回 PHP 勉強会 10
![Page 11: Windows で PHP をビルドしてみた](https://reader034.vdocuments.site/reader034/viewer/2022050800/587068281a28ab48378b564b/html5/thumbnails/11.jpg)
コマンドプロンプトの起動「VS2015 用 MSBuildのコマンドプロンプト」を起動◦ スタートメニューに項目ができているはず
◦ 上の方の項目「Developer Command ...」「MSBuild Command ...」は
◦ 英語版の言語パックを追加したら増えた
◦ 使わないので気にしなくて OK
2014/01/27 第 98 回 PHP 勉強会 11
![Page 12: Windows で PHP をビルドしてみた](https://reader034.vdocuments.site/reader034/viewer/2022050800/587068281a28ab48378b564b/html5/thumbnails/12.jpg)
64 bit ツールセット有効化最初に VC¥vcvarsall.bat amd64を実行する◦ これを忘れると 32 ビット版の PHP が作られる
C:¥Program Files (x86)¥Microsoft Visual Studio 14.0>cd VC
C:¥Program Files (x86)¥Microsoft Visual Studio 14.0¥VC>vcvarsall.bat amd64
C:¥Program Files (x86)¥Microsoft Visual Studio 14.0¥VC>
◦ Microsoft のウェブサイトに情報があります◦ 64 ビットの Visual C++ ツールセットをコマンドラインから有効にする
◦ https://msdn.microsoft.com/ja-jp/library/x4d2c09s.aspx
2014/01/27 第 98 回 PHP 勉強会 12
![Page 13: Windows で PHP をビルドしてみた](https://reader034.vdocuments.site/reader034/viewer/2022050800/587068281a28ab48378b564b/html5/thumbnails/13.jpg)
ビルドの準備公式ウェブサイトに書いてあるとおり
◦ https://wiki.php.net/internals/windows/stepbystepbuild
C:¥Program Files (x86)¥Microsoft Visual Studio 14.0>cd ¥php-sdk
C:¥php-sdk>bin¥phpsdk_setvars.bat
C:¥php-sdk>cd phpdev¥vc14¥x64¥php-7.0.2-src
C:¥php-sdk¥phpdev¥vc14¥x64¥php-7.0.2-src>buildconfRebuilding configure.jsNow run 'configure --help'
C:¥php-sdk¥phpdev¥vc14¥x64¥php-7.0.2-src>
2014/01/27 第 98 回 PHP 勉強会 13
![Page 14: Windows で PHP をビルドしてみた](https://reader034.vdocuments.site/reader034/viewer/2022050800/587068281a28ab48378b564b/html5/thumbnails/14.jpg)
Configure オプション公式ウェブサイトの説明では・・・
◦ --disable-all !!!
◦ いくらなんでもあんまりだ
そこで今回はオプション無しで作ってみます
C:¥php-sdk¥phpdev¥vc14¥x64¥php-7.0.2-src>configure.bat...
C:¥php-sdk¥phpdev¥vc14¥x64¥php-7.0.2-src>
2014/01/27 第 98 回 PHP 勉強会 14
![Page 15: Windows で PHP をビルドしてみた](https://reader034.vdocuments.site/reader034/viewer/2022050800/587068281a28ab48378b564b/html5/thumbnails/15.jpg)
ビルドの実行nmakeコマンドでビルドする
C:¥php-sdk¥phpdev¥vc14¥x64¥php-7.0.2-src>nmake...
ext¥calendar¥jewish.c(346): error C2001: 定数が 2 行目に続いています。ext¥calendar¥jewish.c(347): error C2001: 定数が 2 行目に続いています。ext¥calendar¥jewish.c(365): error C2001: 定数が 2 行目に続いています。ext¥calendar¥jewish.c(366): error C2001: 定数が 2 行目に続いています。ext¥calendar¥jewish.c(368): error C2001: 定数が 2 行目に続いています。
...NMAKE : fatal error U1077: '"C:¥Program Files (x86)¥Microsoft Visual Studio 14.0¥VC¥BIN¥amd64¥cl.exe"' : リターン コード '0x2'
Stop.
C:¥php-sdk¥phpdev¥vc14¥x64¥php-7.0.2-src>
◦ ビルドエラー
2014/01/27 第 98 回 PHP 勉強会 15
![Page 16: Windows で PHP をビルドしてみた](https://reader034.vdocuments.site/reader034/viewer/2022050800/587068281a28ab48378b564b/html5/thumbnails/16.jpg)
jewish.cの修正@yoyaさんのブログに解決方法が書かれていました
◦ http://d.hatena.ne.jp/yoya/20130210/php
◦ ソースコードにヘブライ語が直接書かれているのでエスケープする
2014/01/27 第 98 回 PHP 勉強会 16
![Page 17: Windows で PHP をビルドしてみた](https://reader034.vdocuments.site/reader034/viewer/2022050800/587068281a28ab48378b564b/html5/thumbnails/17.jpg)
あらためてビルド実行今度は無事に成功
C:¥php-sdk¥phpdev¥vc14¥x64¥php-7.0.2-src>nmake...
C:¥php-sdk¥phpdev¥vc14¥x64¥php-7.0.2-src>nmake snap...
C:¥php-sdk¥phpdev¥vc14¥x64¥php-7.0.2-src>
◦ nmake snap でファイル一式を zip にまとめてくれる
2014/01/27 第 98 回 PHP 勉強会 17
![Page 18: Windows で PHP をビルドしてみた](https://reader034.vdocuments.site/reader034/viewer/2022050800/587068281a28ab48378b564b/html5/thumbnails/18.jpg)
完成php-7.0.2-Win32-VC14-x64.zipが生成される
2014/01/27 第 98 回 PHP 勉強会 18
![Page 19: Windows で PHP をビルドしてみた](https://reader034.vdocuments.site/reader034/viewer/2022050800/587068281a28ab48378b564b/html5/thumbnails/19.jpg)
ビルドした PHP を使う適当に展開して実行する
C:¥Users¥Uchiyama>cd C:¥Users¥Uchiyama¥Desktop¥php-7.0.2-Win32-VC14-x64
C:¥Users¥Uchiyama¥Desktop¥php-7.0.2-Win32-VC14-x64>php -vPHP 7.0.2 (cli) (built: Jan 26 2016 23:39:28) ( ZTS )Copyright (c) 1997-2015 The PHP GroupZend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
C:¥Users¥Uchiyama¥Desktop¥php-7.0.2-Win32-VC14-x64>
2014/01/27 第 98 回 PHP 勉強会 19