概要 †
ソースからインストールしたApacheにmod_phpをインストールします。
Apacheのインストールに関しては、以下のページを参照ください。
ソースから導入
手順 †
- 前準備です。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
| -
!
-
!
-
|
!
-
!
-
|
!
-
!
-
|
!
-
!
-
|
!
-
!
-
|
!
-
!
-
|
!
-
!
-
|
!
-
!
-
|
|
!
| yum list | grep libxml2-devel
yum install libxml2-devel
yum list | grep mysql-devel
yum install mysql-devel
yum list | grep gd-devel
yum install gd-devel
yum list | grep libjpeg-devel
yum install libjpeg-devel
yum list | grep libpng-devel
yum install libpng-devel
yum list | grep freetype-devel
yum install freetype-devel
yum list | grep curl-devel
yum install curl-devel
yum list | grep libmcrypt-devel
yum install libmcrypt-devel
yum install libtool-ltdl-devel
|
- ソースをダウンロードします。
1
2
3
| -
|
!
| wget http://www.php.net/get/php-5.3.1.tar.gz/from/jp.php.net/mirror
|
- 展開します。
1
|
| tar zxvf php-5.3.1.tar.gz
|
- 展開先へ移動します。
- makefileを作成します。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| -
!
| './configure' \
'--with-apxs2filter=<Apacheルート>/bin/apxs' \
'--enable-mbstring' \
'--enable-mbregex' \
'--enable-zend-multibyte' \
'--with-zlib' \
'--with-mysql' \
'--enable-sqlite-utf8' \
'--with-gd' \
'--with-jpeg-dir=/usr/lib' \
'--with-png-dir=/usr/lib' \
'--with-zlib-dir=/usr/lib' \
'--with-freetype-dir=/usr/lib' \
'--enable-gd-native-ttf' \
'--disable-gd-jis-conv' \
'--with-curl=/usr/include/curl' \
'--with-mysqli=/usr/bin/mysql_config' \
'--with-mcrypt' \
|
- ビルド、インストールを行ないます。
1
2
3
|
| make
make test
make install
|
- <Apacheルート>/conf/httpd.confを編集します。
1
2
3
4
5
6
7
8
9
10
11
12
| -
|
!
-
|
|
|
|
!
-
|
| LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php
|
- SELinuxを有効にしている場合は、libphp5.soのコンテキストが原因でApacheが起動しなくなる可能性があります
libphp5.soが原因でApacheが起動しないに解決法の1つを書きましたので、参照ください。
- 公開ディレクトリにinfo.phpを作成します。
- アクセスしてphpが動作していることを確認します。
- php.iniをコピーします。
1
2
| -
!
| cp <PHPソースパス>/php.ini-production <phpinfoのConfiguration File Path(php.ini)>
|
- PHPのバージョンが5.3系ならば、タイムゾーンの設定を行ないます。
It is not safe to rely on the system's timezone settings.
- Apacheを再起動します。
1
|
| /etc/init.d/httpd restart
|
- 再度動作を確認し、その後info.phpを削除します。
検証時の環境 †
- CentOS 5.4 x86
- Apache 2.2.14
- mod_php 5.3.1
参考 †