さくらVPSにLAMP環境構築〜php編

2011/12/12

apache,mysqlGDその他ライブラリが準備が整ったとこでいよいよphpインストールしていきます。

phpインストール

ここからソースをDL http://www.php.net/downloads.php

cd /usr/local/src/
$wget http://jp2.php.net/get/php-5.3.8.tar.gz/from/jp.php.net/mirror
$tar xzvf php-5.3.8.tar.gz
$cd php-5.3.8
#./configure –prefix=/usr/local/php5 –with-apxs2=/usr/local/apache2/bin/apxs –disable-all –enable-libxml –with-libxml-dir=/usr/local –enable-zend-multibyte –with-regex=php –enable-filter –with-pcre-regex=yes –with-mysql=/usr/local/mysql –with-gd
$make
$make test

今回configure時に一部権限でエラーを吐いたので、rootで実行しました。
–disable-allオプションを指定してから必要なものだけを入れるようにしてます。
また、オプションは暫定ですので、今後のサービスにより、変更する可能性はあります。
※追記2012/1/27 configureオプション変更がありました。

$./configure –prefix=/usr/local/php5 –with-apxs2=/usr/local/apache2/bin/apxs –disable-all –enable-libxml –with-libxml-dir=/usr/local –enable-zend-multibyte –with-regex=php –enable-filter –with-pcre-regex=yes –with-mysql=/usr/local/mysql –with-gd –with-jpeg-dir –enable-session –enable-mbstring –enable-xml –enable-json –enable-sockets

また、make testでいくつかエラー出たようなので、メモ

=====================================================================
EXPECTED FAILED TEST SUMMARY
———————————————————————
output buffering – fatalism [tests/output/ob_011.phpt] XFAIL REASON: This test will fail until the fix in revision r214155 is backported from php 6

Inconsistencies when accessing protected members [Zend/tests/access_modifiers_008.phpt] XFAIL REASON: Discussion: http://marc.info/?l=php-internals&m=120221184420957&w=2

Inconsistencies when accessing protected members – 2 [Zend/tests/access_modifiers_009.phpt] XFAIL REASON: Discussion: http://marc.info/?l=php-internals&m=120221184420957&w=2

Bug #48770 (call_user_func_array() fails to call parent from inheriting class) [Zend/tests/bug48770.phpt] XFAIL REASON: See Bug #48770

Bug #48770 (call_user_func_array() fails to call parent from inheriting class) [Zend/tests/bug48770_2.phpt] XFAIL REASON: See Bug #48770

Bug #48770 (call_user_func_array() fails to call parent from inheriting class) [Zend/tests/bug48770_3.phpt] XFAIL REASON: See Bug #48770

DateTime::add() — fall type2 type2 [ext/date/tests/DateTime_add-fall-type2-type2.phpt] XFAIL REASON: Various bugs exist

DateTime::add() — fall type2 type3 [ext/date/tests/DateTime_add-fall-type2-type3.phpt] XFAIL REASON: Various bugs exist

DateTime::add() — fall type3 type2 [ext/date/tests/DateTime_add-fall-type3-type2.phpt] XFAIL REASON: Various bugs exist

DateTime::add() — fall type3 type3 [ext/date/tests/DateTime_add-fall-type3-type3.phpt] XFAIL REASON: Various bugs exist

DateTime::add() — spring type2 type2 [ext/date/tests/DateTime_add-spring-type2-type2.phpt] XFAIL REASON: Various bugs exist

DateTime::add() — spring type2 type3 [ext/date/tests/DateTime_add-spring-type2-type3.phpt] XFAIL REASON: Various bugs exist

DateTime::add() — spring type3 type2 [ext/date/tests/DateTime_add-spring-type3-type2.phpt] XFAIL REASON: Various bugs exist

DateTime::add() — spring type3 type3 [ext/date/tests/DateTime_add-spring-type3-type3.phpt] XFAIL REASON: Various bugs exist

DateTime::diff() — fall type2 type2 [ext/date/tests/DateTime_diff-fall-type2-type2.phpt] XFAIL REASON: Various bugs exist

DateTime::diff() — fall type2 type3 [ext/date/tests/DateTime_diff-fall-type2-type3.phpt] XFAIL REASON: Various bugs exist

DateTime::diff() — fall type3 type2 [ext/date/tests/DateTime_diff-fall-type3-type2.phpt] XFAIL REASON: Various bugs exist

DateTime::diff() — fall type3 type3 [ext/date/tests/DateTime_diff-fall-type3-type3.phpt] XFAIL REASON: Various bugs exist

DateTime::diff() — spring type2 type2 [ext/date/tests/DateTime_diff-spring-type2-type2.phpt] XFAIL REASON: Various bugs exist

DateTime::diff() — spring type2 type3 [ext/date/tests/DateTime_diff-spring-type2-type3.phpt] XFAIL REASON: Various bugs exist

DateTime::diff() — spring type3 type2 [ext/date/tests/DateTime_diff-spring-type3-type2.phpt] XFAIL REASON: Various bugs exist

DateTime::diff() — spring type3 type3 [ext/date/tests/DateTime_diff-spring-type3-type3.phpt] XFAIL REASON: Various bugs exist

DateTime::sub() — fall type2 type2 [ext/date/tests/DateTime_sub-fall-type2-type2.phpt] XFAIL REASON: Various bugs exist

DateTime::sub() — fall type2 type3 [ext/date/tests/DateTime_sub-fall-type2-type3.phpt] XFAIL REASON: Various bugs exist

DateTime::sub() — fall type3 type2 [ext/date/tests/DateTime_sub-fall-type3-type2.phpt] XFAIL REASON: Various bugs exist

DateTime::sub() — fall type3 type3 [ext/date/tests/DateTime_sub-fall-type3-type3.phpt] XFAIL REASON: Various bugs exist

DateTime::sub() — spring type2 type2 [ext/date/tests/DateTime_sub-spring-type2-type2.phpt] XFAIL REASON: Various bugs exist

DateTime::sub() — spring type2 type3 [ext/date/tests/DateTime_sub-spring-type2-type3.phpt] XFAIL REASON: Various bugs exist

DateTime::sub() — spring type3 type2 [ext/date/tests/DateTime_sub-spring-type3-type2.phpt] XFAIL REASON: Various bugs exist

DateTime::sub() — spring type3 type3 [ext/date/tests/DateTime_sub-spring-type3-type3.phpt] XFAIL REASON: Various bugs exist

Bug #51994 (date_parse_from_format is parsing invalid date using ‘yz’ format) [ext/date/tests/bug51994.phpt] XFAIL REASON: Bug #51994 isn’t fixed yet

DateTime::add() and sub() result -1 hour on objects with time zone type 2 [ext/date/tests/bug55253.phpt] XFAIL REASON: Bug 55253 exists

一旦無視してmake install

#make install

installログに以下のような記述がありましたので、

libtool: install: warning: remember to run `libtool –finish /usr/local/src/php-5.3.8/libs’

rootで実行しました。

# libtool –finish /usr/local/src/php-5.3.8/libs

httpd.confにphpを関連づける記述も加わってるのが確認できます。

$ less /usr/local/apache2/conf/httpd.conf
LoadModule php5_module modules/libphp5.so

それにphpを動作させる記述を加えます。

AddType application/x-httpd-php .php

動作確認

phpinfo()を見てみましょう。

$ cd /usr/local/apache2/htdocs (ドキュメントルートに移動)
$ vi phpinfo.php

phpinfo.phpの中身

<?php 
phpinfo();
?>

apache再起動

# /usr/local/apache2/bin/httpd -k stop
# /usr/local/apache2/bin/httpd -k start

http://(IPアドレス)/phpinfo.php をブラウザで確認。libxmlやGD、mysqlが無事認識されてました。

LAMP環境完成!

連続でエントリー書いてきました(こちらでまとめてます)が、これでLAMP環境は整ったかと思います。
これ以降は、環境よっては不要かもしれませんが、必要な場合は、参考にしてください。

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です