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

yum install bzip2-devel

zlibのインストール

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

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

tar zxf zlib-1.2.3.tar.gz
cd zlib-1.2.3 ; ./configure --shared ; make -j ; 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/

cd libmcrypt-2.5.8 ; ./configure ; make -j ; make install

cd ./libltdl ; ./configure --enable-ltdl-install ; make -j ; make install ; cd ../../

libxml2のインストール

http://www.xmlsoft.org/

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

./configure ; make -j ; make install ; cd ../

./configure \
--with-pic \
--with-ftp \
--with-history \
--with-http \
--with-iconv=/usr/local \
--with-output \
--with-python \
--with-reader \
--with-regexps \
--with-zlib=/usr/local \

make -j ; make install

cURLのインストール

http://curl.haxx.se/

./configure \
make -j ; make install

libjpegのインストール

http://www.ijg.org/

tar zxf jpegsrc.v9a.tar.gz
cd jpeg-9a ; ./configure --enable-shared --enable-static ; make -j ; make install ; cd ../

FreeTypeのインストール

http://www.freetype.org/

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

libpngのインストール

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

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

make -j CC=gcc ZLIBLIB=/usr/local/lib ZLIBINC=/usr/local/include
make install
cd ../

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

GDのインストール

http://www.libgd.org/
github

cd gd-2.0.35 ; \
./configure \
--with-png=/usr/local \
--with-freetype=/usr/local \
--with-jpeg=/usr/local ; \
make -j ; 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 -j

make install

PHPのインストール

Apache2.0 + PHP4.4

CC=gcc \
CFLAGS="-O3 -mtune=native -I/usr/local/include -I/usr/include" \
LDFLAGS="-L/usr/local/lib64 -L/usr/local/lib -L/usr/lib64 -L/usr/lib -L/lib64 -L/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=native -I/usr/local/include -I/usr/include" \
LDFLAGS="-L/usr/local/lib64 -L/usr/local/lib -L/usr/lib64 -L/usr/lib -L/lib64 -L/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-sockets \
--without-sqlite \
--disable-ipv6 \

PHP 5.4
CC=gcc \
CFLAGS="-O3 -mtune=native -I/usr/local/include -I/usr/include" \
LDFLAGS="-L/usr/local/lib64 -L/usr/local/lib -L/usr/lib64 -L/usr/lib -L/lib64 -L/lib" \
./configure \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysql \
--with-mysqli \
--with-pdo-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-gd \
--with-jpeg-dir=/usr/local \
--with-png-dir=/usr/local \
--with-freetype-dir=/usr/local \
--with-mcrypt=/usr/local \
--with-icu-dir=/usr/local \
--with-pic \
--enable-mbstring \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--enable-ftp \
--enable-bcmath \
--enable-calendar \
--enable-exif \
--enable-soap \
--enable-zip \
--enable-pcntl \
--enable-sysvshm \
--enable-sysvsem \
--enable-sockets \
--enable-mysqlnd \
--disable-ipv6 \

PHP 5.5

CC=gcc \
CFLAGS="-O3 -mtune=native -I/usr/local/include -I/usr/include" \
LDFLAGS="-L/usr/local/lib64 -L/usr/local/lib -L/usr/lib64 -L/usr/lib -L/lib64 -L/lib" \
./configure \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysql \
--with-mysqli \
--with-pdo-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-gd \
--with-jpeg-dir=/usr/local \
--with-png-dir=/usr/local \
--with-freetype-dir=/usr/local \
--with-mcrypt=/usr/local \
--with-icu-dir=/usr/local \
--with-pic \
--enable-mbstring \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--enable-ftp \
--enable-bcmath \
--enable-calendar \
--enable-exif \
--enable-soap \
--enable-zip \
--enable-opcache \
--enable-pcntl \
--enable-sysvshm \
--enable-sysvsem \
--enable-sockets \
--enable-mysqlnd \
--disable-ipv6 \

PHP 5.6

yum install bison bison-devel libzip-devel bzip2-devel
yum install libxml2-devel bzip2-devel freetype-devel openssl-devel zlib-devel libjpeg-turbo-devel libpng-devel libcurl-devel curl-devel libicu-devel gettext-devel

CC=gcc \
CFLAGS="-O3 -mtune=native -I/usr/local/include -I/usr/include" \
LDFLAGS="-L/usr/local/lib64 -L/usr/local/lib -L/usr/lib64 -L/usr/lib -L/lib64 -L/lib" \
./configure \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysql \
--with-mysqli \
--with-pdo-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-gd \
--with-jpeg-dir=/usr/local \
--with-png-dir=/usr/local \
--with-freetype-dir=/usr/local \
--with-mcrypt=/usr/local \
--with-icu-dir=/usr/local \
--with-pic \
--with-gettext \
--enable-mbstring \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--enable-ftp \
--enable-bcmath \
--enable-calendar \
--enable-exif \
--enable-soap \
--enable-zip \
--enable-opcache \
--enable-pcntl \
--enable-sysvshm \
--enable-sysvsem \
--enable-sockets \
--enable-mysqlnd \
--disable-ipv6 \

make -j8 ZEND_EXTRA_LIBS='-liconv'

make -j

make install

PHP 7.0

yum install libxml2-devel bzip2-devel freetype-devel openssl-devel zlib-devel libjpeg-turbo-devel libpng-devel libcurl-devel curl-devel libicu-devel gettext-devel

CC=gcc \
CFLAGS="-O3 -mtune=native -I/usr/local/include -I/usr/include -I/usr/local/mysql/include" \
LDFLAGS="-L/usr/local/lib64 -L/usr/local/lib -L/usr/lib64 -L/usr/lib -L/lib64 -L/lib -L/usr/local/mysql/lib" \
./configure \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-openssl \
--with-openssl-dir=/usr \
--with-xmlrpc \
--with-libxml-dir=/usr \
--with-iconv-dir=/usr \
--with-bz2 \
--with-zlib=/usr \
--with-zlib-dir=/usr \
--with-curl=/usr \
--with-gd \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-freetype-dir=/usr \
--with-mcrypt=/usr \
--with-icu-dir=/usr \
--with-pic \
--with-gettext \
--enable-mbstring \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--enable-ftp \
--enable-bcmath \
--enable-calendar \
--enable-exif \
--enable-soap \
--enable-zip \
--enable-opcache \
--enable-pcntl \
--enable-sysvshm \
--enable-sysvsem \
--enable-sockets \
--enable-mysqlnd \

make -j ZEND_EXTRA_LIBS='-liconv'

make install

PHP 7.1

yum install libxml2-devel bzip2-devel freetype-devel openssl-devel zlib-devel libjpeg-turbo-devel libpng-devel libcurl-devel libicu-devel gettext-devel

CC=gcc \
CFLAGS="-O3 -mtune=native -I/usr/local/include -I/usr/include -I/usr/local/mysql/include" \
LDFLAGS="-L/usr/local/lib64 -L/usr/local/lib -L/usr/lib64 -L/usr/lib -L/lib64 -L/lib -L/usr/local/mysql/lib" \
./configure \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-openssl \
--with-openssl-dir=/usr \
--with-xmlrpc \
--with-libxml-dir=/usr \
--with-iconv-dir=/usr \
--with-bz2 \
--with-zlib=/usr \
--with-zlib-dir=/usr \
--with-curl=/usr \
--with-gd \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-freetype-dir=/usr \
--with-mcrypt=/usr \
--with-icu-dir=/usr \
--with-pic \
--with-gettext \
--enable-mbstring \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--enable-ftp \
--enable-bcmath \
--enable-calendar \
--enable-exif \
--enable-soap \
--enable-zip \
--enable-opcache \
--enable-pcntl \
--enable-sysvshm \
--enable-sysvsem \
--enable-sockets \
--enable-mysqlnd \

make -j ZEND_EXTRA_LIBS='-liconv'

make install

「php.ini」ファイルのコピー
cp php.ini-dist /usr/local/lib/php.ini
cp php.ini-development /usr/local/lib/php.ini
cp php.ini-production /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 clear-cache
pear update-channels
pear channel-update pear.php.net
pear list-upgrades

pear upgrade-all

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 XML_RPC2
pear install Mail_Mime
pear install MIME_TYPE
pear install Mail
pear install Mail_mimeDecode
pear install Net_SMTP
pear install Pager
pear install Net_IPv4

pear install xml_serializer
pear install --alldeps xml_serializer-beta

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;

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

expose_php = Off
magic_quotes_gpc = Off
include_path = ".:/usr/local/lib/php:/usr/local/lib/php/Smarty"
date.timezone = "Asia/Tokyo"
sendmail_path = "/var/qmail/bin/qmail-inject"
session.hash_bits_per_character = 5
mbstring.language = Japanese
mbstring.internal_encoding = SJIS-win
mbstring.http_input = pass
mbstring.http_output = pass
mbstring.encoding_translation = Off
mbstring.detect_order = auto
mbstring.substitute_character = none;
mbstring.func_overload = 0

ファイルアップロード

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

コメントを残す

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