Tips

CalDAV / DAViCALの構築 PHPのインストール

PHPのインストール

インストール手順

(1)PHPのダウンロードと展開

ここで、ようやくPHPのインストールをしていきます。
なぜ、先に「gettext」・「curl」をインストールしたかというと、PHPをインストールする際ののオプション指定の際に、
先にインストールされていないとエラーになる可能性があるからです。
では、PHPのソースコードをダウンロードします。

# cd /usr/local/src ← 「/usr/local/src」ディレクトリに移動

# wget http://jp2.php.net/get/php-5.2.17.tar.gz/from/jp.php.net/mirror ← 「php-5.2.17.tar.gz」ファイルをダウンロード
–2012-08-06 15:39:28– http://jp2.php.net/get/php-5.2.17.tar.gz/from/jp.php.net/mirror
jp2.php.net をDNSに問いあわせています… 49.212.134.217
jp2.php.net|49.212.134.217|:80 に接続しています… 接続しました。
HTTP による接続要求を送信しました、応答を待っています… 302 Found
場所: http://jp.php.net/distributions/php-5.2.17.tar.gz [続く]
–2012-08-06 15:39:28– http://jp.php.net/distributions/php-5.2.17.tar.gz
jp.php.net をDNSに問いあわせています… 61.195.146.164
jp.php.net|61.195.146.164|:80 に接続しています… 接続しました。
HTTP による接続要求を送信しました、応答を待っています… 200 OK
長さ: 11801597 (11M) [application/x-gzip]
`php-5.2.17.tar.gz’ に保存中100%[===================================================================================>] 11,801,597 1.83M/s 時間 4.6s2012-08-06 15:39:33 (2.45 MB/s) – `php-5.2.17.tar.gz’ へ保存完了 [11801597/11801597]

ダウンロードした「php-5.2.17.tar.gz」ファイルを展開します。

# tar xfz php-5.2.17.tar.gz ← 「php-5.2.17.tar.gz」ファイルを展開
※「php」の本家サイト

・URL

(2)Configureの実施とインストール

展開されたディレクトリ「php-5.2.17.tar.gz」に移動し、Configureを実行してMakefileを作成します。
※ソースコードの最新版は、本家サイトで確認してください。

# cd php-5.2.17 ← 「php-5.2.17」に移動

# ./configure  ← Confiureの実施
> –with-apxs2=/usr/local/apache2/bin/apxs  ← Apache 2.0 共有モジュールをビルド
> –with-pgsql=/usr/local/pgsql  ← PostgreSQLのパスを指定
> –with-pdo-pgsql=/usr/local/pgsql
> –enable-mbstring  ← マルチバイト関数をサポート
> –enable-mbregex
> –enable-ftp
> –enable-zip
> –enable-calendar
> –with-gettext=/usr/local  ← gettextのパスを指定
> –with-curl=/usr/local  ← curlのパスを指定
> –with-curlwrappers
loading cache ./config.cache
checking for Cygwin environment… (cached) no
checking for mingw32 environment… (cached) no
checking for egrep… (cached) grep -E
checking for a sed that does not truncate output… (cached) /bin/sed
checking host system type… i686-pc-linux-gnu
checking target system type… i686-pc-linux-gnu
checking for gcc… (cached) gcc
checking whether the C compiler (gcc ) works… yes
checking whether the C compiler (gcc ) is a cross-compiler… no
checking whether we are using GNU C… (cached) yes
checking whether gcc accepts -g… (cached) yes
checking how to run the C preprocessor… (cached) gcc -E
checking for icc… no
checking for suncc… no
checking whether gcc and cc understand -c and -o together… (cached) yes
checking how to run the C preprocessor… gcc -E
checking for AIX… no
・・・省略・・・

特にエラーが出なければ、makeを行います。

# make ← makeの実施
/bin/sh /usr/local/src/php-5.2.17/libtool –silent –preserve-dup-deps –mode=compile gcc -Iext/date/lib -Iext/date/ -I/usr/local/src/php-5.2.17/ext/date/ -DPHP_ATOM_INC -I/usr/local/src/php-5.2.17/include -I/usr/local/src/php-5.2.17/main -I/usr/local/src/php-5.2.17 -I/usr/local/src/php-5.2.17/ext/date/lib -I/usr/include/libxml2 -I/usr/local/include -I/usr/local/src/php-5.2.17/ext/mbstring/oniguruma -I/usr/local/src/php-5.2.17/ext/mbstring/libmbfl -I/usr/local/src/php-5.2.17/ext/mbstring/libmbfl/mbfl -I/usr/local/pgsql/include -I/usr/local/src/php-5.2.17/TSRM -I/usr/local/src/php-5.2.17/Zend -I/usr/include -g -O2 -prefer-non-pic -c /usr/local/src/php-5.2.17/ext/date/php_date.c -o ext/date/php_date.lo
/bin/sh /usr/local/src/php-5.2.17/libtool –silent –preserve-dup-deps –mode=compile gcc -Iext/date/lib -Iext/date/ -I/usr/local/src/php-5.2.17/ext/date/ -DPHP_ATOM_INC -I/usr/local/src/php-5.2.17/include -I/usr/local/src/php-5.2.17/main -I/usr/local/src/php-5.2.17 -I/usr/local/src/php-5.2.17/ext/date/lib -I/usr/include/libxml2 -I/usr/local/include -I/usr/local/src/php-5.2.17/ext/mbstring/oniguruma -I/usr/local/src/php-5.2.17/ext/mbstring/libmbfl -I/usr/local/src/php-5.2.17/ext/mbstring/libmbfl/mbfl -I/usr/local/pgsql/include -I/usr/local/src/php-5.2.17/TSRM -I/usr/local/src/php-5.2.17/Zend -I/usr/include -g -O2 -prefer-non-pic -c /usr/local/src/php-5.2.17/ext/date/lib/astro.c -o ext/date/lib/astro.lo
/bin/sh /usr/local/src/php-5.2.17/libtool –silent –preserve-dup-deps –mode=compile gcc -Iext/date/lib -Iext/date/ -I/usr/local/src/php-5.2.17/ext/date/ -DPHP_ATOM_INC -I/usr/local/src/php-5.2.17/include -I/usr/local/src/php-5.2.17/main -I/usr/local/src/php-5.2.17 -I/usr/local/src/php-5.2.17/ext/date/lib -I/usr/include/libxml2 -I/usr/local/include -I/usr/local/src/php-5.2.17/ext/mbstring/oniguruma -I/usr/local/src/php-5.2.17/ext/mbstring/libmbfl -I/usr/local/src/php-5.2.17/ext/mbstring/libmbfl/mbfl -I/usr/local/pgsql/include -I/usr/local/src/php-5.2.17/TSRM -I/usr/local/src/php-5.2.17/Zend -I/usr/include -g -O2 -prefer-non-pic -c /usr/local/src/php-5.2.17/ext/date/lib/dow.c -o ext/date/lib/dow.lo
/bin/sh /usr/local/src/php-5.2.17/libtool –silent –preserve-dup-deps –mode=compile gcc -Iext/date/lib -Iext/date/ -I/usr/local/src/php-5.2.17/ext/date/ -DPHP_ATOM_INC -I/usr/local/src/php-5.2.17/include -I/usr/local/src/php-5.2.17/main -I/usr/local/src/php-5.2.17 -I/usr/local/src/php-5.2.17/ext/date/lib -I/usr/include/libxml2 -I/usr/local/include -I/usr/local/src/php-5.2.17/ext/mbstring/oniguruma -I/usr/local/src/php-5.2.17/ext/mbstring/libmbfl -I/usr/local/src/php-5.2.17/ext/mbstring/libmbfl/mbfl -I/usr/local/pgsql/include -I/usr/local/src/php-5.2.17/TSRM -I/usr/local/src/php-5.2.17/Zend -I/usr/include -g -O2 -prefer-non-pic -c /usr/local/src/php-5.2.17/ext/date/lib/parse_date.c -o ext/date/lib/parse_date.lo

・・・省略・・・

特にエラーが出なければ、make installにて、インストールを行います。

# make install ← インストールの実施
Installing PHP SAPI module: apache2handler
/usr/local/apache2/build/instdso.sh SH_LIBTOOL=’/usr/local/apache2/build/libtool’ libphp5.la /usr/local/apache2/modules
/usr/local/apache2/build/libtool –mode=install cp libphp5.la /usr/local/apache2/modules/
cp .libs/libphp5.so /usr/local/apache2/modules/libphp5.so
cp .libs/libphp5.lai /usr/local/apache2/modules/libphp5.la
libtool: install: warning: remember to run `libtool –finish /usr/local/src/php-5.2.17/libs’
chmod 755 /usr/local/apache2/modules/libphp5.so
[activating module `php5′ in /usr/local/apache2/conf/httpd.conf] Installing PHP CLI binary: /usr/local/bin/
Installing PHP CLI man page: /usr/local/man/man1/
Installing build environment: /usr/local/lib/php/build/
Installing header files: /usr/local/include/php/
Installing helper programs: /usr/local/bin/
program: phpize
program: php-config
Installing man pages: /usr/local/man/man1/
page: phpize.1
page: php-config.1
Installing PEAR environment: /usr/local/lib/php/
[PEAR] Archive_Tar – installed: 1.3.7
[PEAR] Console_Getopt – installed: 1.2.3
[PEAR] Structures_Graph- installed: 1.0.3
[PEAR] XML_Util – installed: 1.2.1
[PEAR] PEAR – installed: 1.9.1
Wrote PEAR system config file at: /usr/local/etc/pear.conf
You may want to add: /usr/local/lib/php to your php.ini include_path
Installing PDO headers: /usr/local/include/php/ext/pdo/

(3)PHPの環境設定

特にエラーが出なければ、あとは、PHPの環境設定を行う必要があります。
まず、PHPの共有ライブラリを参照できるようにldconfigの設定を行うために、「/etc/ld.so.conf.d/php.conf」ファイルを作成し、設定を反映させます。

# vi /etc/ld.so.conf.d/php.conf ← viコマンドにて、php用のライブラリの設定ファイルを作成

# ldconfig ← 設定内容を反映

以下が「/etc/ld.so.conf.d/php.conf」ファイルの内容となります。

/usr/local/lib

あとは、Apacheの設定ファイル「httpd.conf」に、次の設定を追加します。

追加の内容

AddType application/x-httpd-php .php

 

# vi /usr/local/apache2/conf/httpd.conf ← viコマンドにて、php用の設定項目を追加

 

Linux認定資格 LPICを取るなら・・

Linux資格 「LPIC Lv1」徹底解説 連載目次

Recent News

Recent Tips

Tag Search