PHP :: インストール / Unix (debian)

● 展開 & configure

% tar -vxzf php-5.2.0.tar.gz
% cd php-5.2.0
% ./configure \
--enable-bcmath \
--enable-calendar \
--enable-dio \
--enable-exif \
--enable-ftp \
--enable-mbstring \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-yp \
--enable-zend-multibyte \
--prefix=/usr \
--with-apxs \
--with-bz2 \
--with-config-file-path=/etc \
--with-gettext \
--with-libmbfl \
--with-mime-magic \
--with-mod_charset \
--with-mysql=/usr/local/bin/mysql \
--with-pdo-mysql=/usr/local/bin/mysql \
--with-ncurses \
--with-gd --with-jpeg-dir=/usr --with-zlib-dir=/usr --with-freetype-dir=/usr \
--enable-gd-jis-conv \
--enable-gd-native-ttf \
--with-t1lib \
--with-ttf \
--enable-sqlite-utf8 \
--with-pgsql \
--with-flatfile \
--with-inifile

エラーが出たら、このページ中~下段の[エラーと対処]を参照。


● make & install

% make
% sudo make install


● 確認

% php -v



● php.ini の設定

% sudo cp php.ini-dist /usr/local/lib/php.ini
% sudo vi /usr/local/lib/php.ini
mbstring.language = Japanese
mbstring.internal_encoding = EUC-JP
mbstring.http_input = auto
mbstring.http_output = EUC-JP
mbstring.encoding_translation = On
mbstring.detect_order = auto
mbstring.substitute_character = none
mbstring.func_overload = 0
mbstring.strict_encoding = Off


● httpd.conf の設定

% sudo vi /path/to/httpd.conf
DirectoryIndex index.php index.html

<IfModule mod_mime.c>
    AddType application/x-httpd-php .php
</IfModule>

LoadModule php5_module /usr/local/stow/apache_1.3.37-1/libexec/libphp5.so

<Directory "/home/www/htdocs">
    Options -Indexes FollowSymLinks MultiViews
    AllowOverride All
</Directory>


● .htaccess の設定

#^^^^^^^^^^^#
# php_error #
#...........#
# E_ALL=2047 ^ E_NOTICE=1024
php_value error_reporting 2047
php_value display_errors 1
php_value log_errors 1
php_value error_log "/var/tmp/php_error_log"

#^^^^^^^^^^^^^^#
# php_settings #
#..............#
php_value include_path .:/usr/local/lib/php
php_value mbstring_http_output  pass
php_value mbstring_detect_order SJIS,EUC-JP
php_flag  magic_quotes_gpc      Off
php_flag  magic_quotes_runtime  Off
php_flag  register_globals      Off





[エラーと対処]


bz2 関連(Bzip2 圧縮関数を有効にする)

configure: error: Please reinstall the BZip2 distribution
% sudo apt-get install libbz2-dev


gd 関連

configure: error: libjpeg.(a|so) not found.
% wget http://www.ijg.org/files/jpegsrc.v6b.tar.gz
% tar vxzf jpegsrc.v6b.tar.gz
% cd jpeg-6b
% ./configure --enable-shared
% make
% sudo make install


gd 関連

configure: error: freetype2 not found!
% wget 'http://downloads.sourceforge.net/freetype/freetype-2.3.0.tar.gz?modtime=1169048835&big_mirror=0'
% cd freetype-2.3.0
% make setup
% make
% sudo make install


gd 関連

configure: error: Your t1lib distribution is not installed correctly. Please reinstall it. 
% sudo apt-get install t1lib-dev


gd 関連

configure: error: Problem with libt1.(a|so). Please check config.log for more information.
% sudo apt-get install libt1-dev


imap 関連

configure: error: Cannot find rfc822.h. Please check your c-client installation.
% wget http://www.mirror.ac.uk/mirror/ftp.cac.washington.edu/mail/c-client.tar.Z
% tar vxzf c-client.tar.Z
% cd imap-2006d/
% make lrh
% cd c-client
% sudo cp c-client.a /usr/local/lib
% sudo ln -s /usr/local/lib/c-client.a /usr/local/lib/libc-client.a 
% sudo cp linkage.h /usr/local/include
% sudo cp mail.h /usr/local/include
% sudo cp rfc822.h /usr/local/include


postgresql 関連

configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path
% sudo apt-get install postgresql-dev

postgres使わなければ –with-pgsql をコメントにすれば出ない?(未確認)