Home > PHPのインストール

PHPのインストール

  • 2009-10-23 (金) 14:01

http://www.php.net/
PHP自体をインストールする前にライブラリなどを先にインストールしておく。

zlibのインストール

http://www.gzip.org/zlib/

tar zxf zlib-1.2.3.tar.gz
cd zlib-1.2.3 ; ./configure --shared ; make ; make install ; cd ../

IMAPのインストール

http://www.imap.org/
ftp://ftp.cac.washington.edu/imap/imap.tar.Z
ftp://ftp.cac.washington.edu/imap/

IMAP 2004gの場合(最近使ってない)
make slx SSLTYPE=none

古いやつを削除
rm -f /usr/local/lib/libc-client.a
rm -f /usr/local/include/c-client.h
rm -f /usr/local/include/imap4r1.h
rm -f /usr/local/include/rfc822.h
rm -f /usr/local/include/mail.h
rm -f /usr/local/include/linkage.h
rm -f /usr/local/include/env.h
rm -f /usr/local/include/env_unix.h
rm -f /usr/local/include/fs.h
rm -f /usr/local/include/ftl.h
rm -f /usr/local/include/misc.h
rm -f /usr/local/include/nntp.h
rm -f /usr/local/include/nl.h
rm -f /usr/local/include/osdep.h
rm -f /usr/local/include/smtp.h
rm -f /usr/local/include/tcp.h

コンパイルしたものをコピーする
cp -f c-client/c-client.a /usr/local/lib/libc-client.a
cp -f c-client/c-client.h /usr/local/include/
cp -f c-client/imap4r1.h /usr/local/include/
cp -f c-client/rfc822.h /usr/local/include/
cp -f c-client/mail.h /usr/local/include/
cp -f c-client/linkage.h /usr/local/include/
cp -f c-client/env.h /usr/local/include/
cp -f c-client/env_unix.h /usr/local/include/
cp -f c-client/fs.h /usr/local/include/
cp -f c-client/ftl.h /usr/local/include/
cp -f c-client/misc.h /usr/local/include/
cp -f c-client/nntp.h /usr/local/include/
cp -f c-client/nl.h /usr/local/include/
cp -f c-client/osdep.h /usr/local/include/
cp -f c-client/smtp.h /usr/local/include/
cp -f c-client/tcp.h /usr/local/include/

libmcryptのインストール

http://mcrypt.sourceforge.net/

./configure

make

make install

cd ./libltdl

./configure --enable-ltdl-install

make

make install

libxml2のインストール

http://www.xmlsoft.org/

libxml2のインストール PHP5で必要 2.5以上

./configure ; make ; make install ; cd ../

で大丈夫だと思う。

cURLのインストール

http://curl.haxx.se/

./configure \
--with-ssl \
--with-zlib \
--enable-http \
--enable-ftp \
--enable-file \
--enable-telnet \
--enable-cookies ; \
make ; make install

libjpegのインストール

http://www.ijg.org/

tar zxf jpegsrc.v7.tar.gz
cd jpeg-7 ; ./configure --enable-shared --enable-static ; make ; make install ; cd ../

(libtoolが古いから./libtoolを/usr/bin/libtoolをMailfileに直接書き直す必要があるかも)

FreeTypeのインストール

http://www.freetype.org/

tar zxf freetype-2.3.11.tar.gz
cd freetype-2.3.11 ; ./configure ; make ; make install ; cd ../

libpngのインストール

http://www.libpng.org/pub/png/libpng.html

tar zxf libpng-1.2.40.tar.gz
cd libpng-1.2.40 ; cp scripts/makefile.linux makefile

make CC=gcc ZLIBLIB=/usr/local/lib ZLIBINC=/usr/local/include
make install

-----------------------------------------

tar zxf libpng-1.2.40.tar.gz
cd libpng-1.2.40 ; cp scripts/makefile.linux makefile ; vi makefile

-----------------------------------------
#ZLIBLIB=/usr/local/lib
#ZLIBINC=/usr/local/include
ZLIBLIB=../zlib
ZLIBINC=../zlib
-----------------------------------------
↓以下に修正
-----------------------------------------
ZLIBLIB=/usr/local/lib
ZLIBINC=/usr/local/include
#ZLIBLIB=../zlib
#ZLIBINC=../zlib
-----------------------------------------

make ; make install ; cd ../

GDのインストール

http://www.libgd.org/

cd gd-2.0.35 ; \
./configure \
--with-png=/usr/local \
--with-freetype=/usr/local \
--with-jpeg=/usr/local ; \
make ; make install ; cd ../

tidyのインストール(必要であれば)

cvs -d:pserver:anonymous@tidy.cvs.sourceforge.net:/cvsroot/tidy login

cvs -z3 -d:pserver:anonymous@tidy.cvs.sourceforge.net:/cvsroot/tidy co -P tidy

cd /usr/local/src/tidy

/bin/sh build/gnuauto/setup.sh

./configure --enable-asian

make

make install

PHPのインストール

Apache2.0 + PHP4.4

CC=gcc \
CFLAGS="-O3 -mtune=core2 -I/usr/local/include" \
LDFLAGS="-L/usr/local/lib" \
./configure \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysql=/usr/local/mysql \
--with-zlib=/usr/local \
--with-zlib-dir=/usr/local \
--with-jpeg-dir=/usr/local \
--with-png-dir=/usr/local \
--with-freetype-dir=/usr/local \
--with-gd=/usr/local \
--with-imap=/usr/local \
--with-curl=/usr/local \
--with-dom=/usr/local \
--with-iconv=/usr/local \
--with-iconv-dir=/usr/local \
--with-openssl \
--with-mime-magic \
--with-bz2 \
--enable-mbstring \
--enable-zend-multibyte \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--enable-calendar \
--enable-exif \
--enable-ftp \
--disable-ipv6 \

Apache2.2 + PHP5.2

ノーマル
CC=gcc \
CFLAGS="-O3 -mtune=core2 -I/usr/local/include" \
LDFLAGS="-L/usr/local/lib" \
./configure \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-pdo-mysql=/usr/local/mysql \
--with-openssl \
--with-openssl-dir=/usr/local \
--with-xmlrpc \
--with-libxml-dir=/usr/local \
--with-iconv-dir=/usr/local \
--with-bz2 \
--with-zlib=/usr/local \
--with-zlib-dir=/usr/local \
--with-curl=/usr/local \
--with-curlwrappers \
--with-mime-magic \
--with-gd \
--with-jpeg-dir=/usr/local \
--with-png-dir=/usr/local \
--with-freetype-dir=/usr/local \
--with-mcrypt=/usr/local \
--with-pic \
--enable-mbstring \
--enable-zend-multibyte \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--enable-ftp \
--enable-bcmath \
--enable-calendar \
--enable-exif \
--enable-soap \
--enable-zip \
--enable-pcntl \
--without-sqlite \
--disable-ipv6 \

make

make install

「php.ini」ファイルのコピー
cp php.ini-dist /usr/local/lib/php.ini

httpd.conf 以下は拡張子の設定(こっちは手動で記述しなければならない。)
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps

Windows版は以下を追加
LoadModule php5_module "c:/php/php5apache2_2.dll"
PHPIniDir "C:/php"

Windows版ログローテート
CustomLog "|\"C:/Apache2.2/bin/rotatelogs.exe\" \"C:/Apache2.2/logs/access.log_%Y%m%d\" 86400 540" combined
CustomLog "|\"C:/Apache2.2/bin/rotatelogs.exe\" \"C:/Apache2.2/logs/error.log_%Y%m%d\" 86400 540" combined

PEAR関連

pear update-channels
pear channel-update pear.php.net

pear upgrade-all

pear channel-update pear.php.net
pear list-upgrades

pear install HTTP_Request
pear install HTTP_Request2

Pear DBはもう古いからMDB2を使えって
pear install DB

pear install MDB2
pear install MDB2#MySQL
pear install MDB2#MySQLi
pear install MDB2#PostgreSQL
pear install MDB2#SQLite2

pear install XML_RPC
pear install Mail_Mime
pear install MIME_TYPE
pear install Mail
pear install Net_SMTP
pear install Pager
pear install Net_IPv4

php.iniの設定

Magic quotesをOFF
magic_quotes_gpc = Off

sendmailのパスの指定(qmailを指定)
sendmail_path = "/var/qmail/bin/qmail-inject"

タイムゾーン関連
date.timezone = "Asia/Tokyo"

mbstring関連
日本語関連の設定
ポリシーとして、SJISを前提に処理するが
基本的に、エンコードは何もせずに入ってきたものはそのまま出す

mbstring.language = Japanese
mbstring.internal_encoding = SJIS-win
mbstring.http_input = pass
mbstring.http_output = pass
mbstring.encoding_translation = Off
mbstring.substitute_character = none;

ファイルアップロード

upload_max_filesize = 16M
post_max_size = 16M

max_execution_time = 300
max_input_time = 600
memory_limit = 16M

X-Powered-By: PHP/x.x.x
expose_php = Off

Smartyの設定

http://www.smarty.net/

mkdir /usr/local/lib/php/Smarty

解凍したSmartyフォルダの中のlibsの中をコピーする。

php.iniにパスを追加する。
include_path = ".:/usr/local/lib/php:/usr/local/lib/php/Smarty"

コマンドラインのパスの設定

コマンドラインから、Apacheの再起動、MySQLの操作などすると思うが
このままだとパスが通ってないので、フルパスでコマンドを打たないといけない。
面倒なので、パスを通しておく。

エディタで「/etc/profile」を開いて、6行目を編集。

PATH="$PATH:/usr/X11R6/bin"

PATH="$PATH:/usr/X11R6/bin:/usr/local/apache2/bin:/usr/local/mysql/bin:/usr/local/samba/bin:/usr/local/samba/sbin:/var/qmail/bin"

これでApacheとMySQLのパスが追加されました。

サーバーリブート後に反映されているはず。

又は

source /etc/profile

で反映させる。

※「source」は「.」で代用できるらしい

. /etc/profile

ldcofig
最新の共有ライブラリに対して必要なリンクを作成したり、ライブラリをキャッシュしたりする。

vi /etc/ld.so.conf

/usr/local/bin
/usr/local/lib
/usr/local/mysql/bin
/usr/local/mysql/lib/mysql
/usr/local/mysql/include/mysql

ldconfig

http://www.linux.or.jp/JM/html/LDP_man-pages/man8/ldconfig.8.html

Comments:0

Comment Form
Remember personal info

Trackbacks:0

Trackback URL for this entry
http://acoustype.com/php%e3%81%ae%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab/trackback
Listed below are links to weblogs that reference
PHPのインストール from acoustype.com

Home > PHPのインストール

Search
Feeds
Meta

Return to page top