LoginSignup
0
1

More than 5 years have passed since last update.

PHP7インストールメモ 〜ソースファイルから〜

Posted at

FreeBSD10.3 で poots や pkg コマンドを使わないでphp7をインストールした時のメモ

参考
PHP 7 正式版をソースファイルからインストールして試してみる

php7インストール

ダウンロード

http://php.net/get/php-7.1.3.tar.bz2/from/a/mirror よりダウンロード
スクリーンショット 2017-03-23 16.26.48.png

※ 参考にしたURL先では、wgetコマンドを使用していましたが、環境によっては使用できません。代わりにcurlコマンドを使ってみてもいいかもしれません。

コマンド使う例
% wget http://jp2.php.net/get/php-7.0.0.tar.gz/from/this/mirror -O php-7.0.0.tar.gz
% curl http://jp2.php.net/get/php-7.0.0.tar.gz/from/this/mirror -o php-7.0.0.tar.gz   <curlはオプションが違うぞっと>

※ portsやpkgコマンドでインストールするときにはこちらを参考にみるといいかも
参考
apache,php,MySQLをpkgからインストール

展開、ビルド、make

ダウンロードしたファイルを実行マシン(今回はFreeBSD)に持っていき、展開。
展開したファイルをconfig、make をします。
自分の環境下でphpの実行まで確認できるので、確認してからサーバへの設定をしたほうがいいです。
php7はfastcgiはすでに含まれているのでビルドする時に追加するとかしなくてもいいみたいです。

% tar jxvf php-7.1.3.tar.bz2  <ー展開
x php-7.1.3/
x php-7.1.3/generated_lists
:
x php-7.1.3/win32/ftok.c
x php-7.1.3/win32/select.c
% ls
php-7.1.3.tar.bz2   php-7.1.3
% cd php-7.1.3               <ー 移動
% ./configure --help | less    <ー helpしてみて確認してみるのもいい
% ./configure                 <ー ビルドしてみる
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking build system type... i386-unknown-freebsd10.3
:
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands
% make                               <ー makeしてみる
/bin/sh /export/home/***/php-7.1.3/libtool --silent --preserve-dup-deps --mode=compile cc -D・・・・・
:
Build complete.
Don't forget to run 'make test'.

% make test                <ー レグレッションテスト。phpが動作するか確認
:
FAILED TEST SUMMARY             <ーなにか失敗したリストがでる。問題なければ放置
:
Do you want to send this report now? [Yns]: n   <ーエラーリストレポートがいらないなら[n]

自分環境で動作できるようになったはずなのでコマンドラインで確認します。
(実行phpがわからないときはgrepで探す)

% find . | grep php
./php.gif
./pear/fetch.php
:
./sapi/cgi/php-cgi     <ー発見
:
% ./sapi/cgi/php-cgi    <ー実行して確認
<?php phpinfo()?>          <ー入力待ちモードになるのでphpスクリプトをいれてファイル打ち終わったよで CTRL-d をすると結果が出て来る
X-Powered-By: PHP/7.1.3
Content-type: text/html; charset=UTF-8

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
:
:

あとは、本体サーバに sapi/cgi/php-cgi を適応させれば動きます。

おまけ

phpにはビルトインウェブサーバーという便利な機能がついていて、アパッチの設定ができていなくでもphpの実行を試せれるのです。
参考
PHP(5.4.0以降)でビルトインウェブサーバーを使う
ビルトインウェブサーバー

たとえば、macローカル環境で、mampとか入っていないけどphpは入っている場合
ブラウザで確認できちゃいます。

macローカルにいれたpukiwikiをみたいぞっていう例
$ cd wiki
$ ls
:
$ php -S localhost:9999    <ーポートは適当
PHP 5.6.10 Development Server started at Thu Mar 23 17:56:57 2017
Listening on http://localhost:9999
Document root is /Users/***/Devmamp/wiki
Press Ctrl-C to quit.

この状態でとまります。ブラウザで  [http://localhost:9999]  にアクセス
スクリーンショット 2017-03-23 17.59.35.png
表示されるのです。
ちょっとした確認なら楽ちんですね〜
ターミナルはCtrl+Cで終了。

参考
PukiWikiのインストール

0
1
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
0
1