Ubuntu12.04LTS上で、php5.5
をソースからコンパイルした手順に関するメモ
libjpegのビルド
※2014/05/23更新
–with-gd
だけではjpeg
がサポートされないことがわかった。
phpビルド前にlibjpeg
をコンパイルする処理を追加
# wget http://www.ijg.org/files/jpegsrc.v8.tar.gz
# tar xzf jpegsrc.v8.tar.gz
# cd jpeg-8/
# ./configure –prefix=/usr/local –enable-shared –enable-static
# make
# sudo make install
phpのビルド
ミラーサイトから取得(mirrorというファイル名でDL)
# wget http://jp1.php.net/get/php-5.5.11.tar.gz/from/this/mirror
解凍&移動
# tar xvf mirror
# cd php-5.5.11
Makefile作成
> ./configure \
--prefix=/usr/local/php/php5.5.11 \
--with-config-file-path=/usr/local/php/php5.5.11/etc \
--with-apxs2=/usr/local/httpd/current/bin/apxs \
--with-mysql \
--enable-exif \
--with-zlib \
--enable-zip \
--with-openssl \
--enable-mbstring \
--with-pdo-mysql \
--with-mysql-sock \
--with-jpeg-dir=/usr/local/lib \
--with-gd \
--enable-gd-native-ttf \
ビルド、ビルド後のテストおよびインストール
# make
# sudo make install
Installing PHP SAPI module: apache2handler
/usr/local/httpd/httpd-2.4.6/build/instdso.sh SH_LIBTOOL=’/usr/local/apr/apr-1.4.8/build-1/libtool’ libphp5.la /usr/local/httpd/httpd-2.4.6/modules
/usr/local/apr/apr-1.4.8/build-1/libtool –mode=install install libphp5.la /usr/local/httpd/httpd-2.4.6/modules/
:
Installing PDO headers: /usr/local/php/php5.5.11/include/php/ext/pdo/
シンボリックリンクの作成
# cd /usr/local/php
# sudo ln -s php5.5.11/ current
phpモジュールから情報を取得
どんなオプションでビルドされたのか、設定ファイルphp.ini
の場所はどこかなどの情報を表示
# /usr/local/php/current/bin/php -i
設定ファイルをコピー
# cp php.ini-development /usr/local/php/php5.5.11/etc/php.ini
デフォルト値からの変更点
> diff php.ini php.ini-development
< max_execution_time = 3600 > max_execution_time = 30
< memory_limit = 3000M > memory_limit = 128M
< error_log = (ログ出力先)/logs/php.log < post_max_size = 3000M > post_max_size = 8M
< upload_tmp_dir = /home/share/Temp/ > ;upload_tmp_dir =
< upload_max_filesize = 1000M > upload_max_filesize = 2M
< max_file_uploads = 1000 > max_file_uploads = 20
< mbstring.language = Japanese > ;mbstring.language = Japanese
< mbstring.internal_encoding = UTF-8 > ;mbstring.internal_encoding = UTF-8
< mbstring.http_input = UTF-8 > ;mbstring.http_input = UTF-8
< mbstring.http_output = UTF-8 > ;mbstring.http_output = pass
< mbstring.encoding_translation = On > ;mbstring.encoding_translation = Off
Apacheの設定
mime.types
text/html html htm php phps
libphp5.so
Apacheインストール先のmodulesディレクトリにlibphp5.soが存在することを確認する
httpd.conf
LoadModule php5_module modules/libphp5.so
<filesmatch ".+\.ph(p[345]?|t|tml)$">
SetHandler application/x-httpd-php
</filesmatch>
<filesmatch ".+\.phps$">
SetHandler application/x-httpd-php-source
# Deny access to raw php sources by default
# To re-enable it's recommended to enable access to the files
# only in specific virtual host or directory
Order Deny,Allow
Deny from all
</filesmatch>
<filesmatch "^\.ph(p[345]?|t|tml|ps)$">
Order Deny,Allow
Deny from all
</filesmatch>
<ifmodule mod_userdir.c="">
<directory home="" *="" public_html="">
php_admin_value engine Off
</directory>
</ifmodule>