HOME > Magento 構築TIPS > 2.phpのインストール

TIPS

2.phpのインストール

YumでRPM管理する為、レポジトリを追加しないとphpを5.2.xにバージョンアップできません。
よってソースからインストールします。

2.1.apache configのバックアップ

phpインストール時にhttpd.confの内容が書き変わってしまうのでバックアップを取ります。

% su -
# cd /etc/httpd/conf
# cp httpd.conf httpd.conf.20090416

2.2.phpのインストール準備

with-apxs2、httpd-develとlibxml2-devel、
with-curl、curl-devel、with-jpeg、with-pngでlibjpeg-devel、libpng-devel、
with-mysqlでmysql-develとlibmcrypt-devel等が必要なので入れておきます。

% su -
# yum -y install httpd-devel
# yum -y install libxml2-devel
# yum -y install curl-devel
# yum -y install libjpeg-devel
# yum -y install libpng-devel
# yum install mysql-devel
# yum install libmcrypt-devel

2.3.phpダウンロード

http://jp.php.net/にて最新のPHPを選択します。(今回はphp-5.2.9が最新)

% cd /usr/local/src/php
% wget http://jp.php.net/get/php-5.2.9.tar.gz/from/jp2.php.net/mirror

2.4.phpインストール

% cd /usr/local/src/php
% tar zxvf php-5.2.9.tar.gz
% cd php-5.2.9
% ./configure \
--prefix=/usr/local/php-5.2.9 \
--enable-mbstring \
--enable-mbregex \
--with-mysql \
--with-pdo_mysql \
--with-apxs2=/usr/sbin/apxs \
--with-mcrypt \
--with-curl \
--with-gd \
--with-zlib \
--with-jpeg-dir=/usr/lib/ \
--with-png-dir=/usr/lib/

% make
% make test
% su
# make install

2.5.php.iniのコピー

# cd /usr/local/src/php/php-5.2.9
# cp php.ini-dist /usr/local/lib/php.ini
# cd /usr/local/lib/

2.6.php.iniの編集

output_buffering = On, default_charset = "UTF-8", date.timezone = "Asia/Tokyo"と設定します。
# vi php.ini
# diff php.ini /usr/local/src/php/php-5.2.9/php.ini-dist
< output_buffering = On
---
> output_buffering = Off
464d463
< default_charset = "UTF-8"
664d662
< date.timezone = "Asia/Tokyo"
# /etc/rc.d/init.d/httpd configtest
Syntax OK
# /etc/rc.d/init.d/httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

2.7.apacheの設定

httpd.confのLoadModule php5_module部分をコメントアウトしないとエラーになります。

# cd /etc/httpd/conf
# vi httpd.conf

・httpd.conf

#LoadModule php5_module        /usr/lib/httpd/modules/libphp5.so

magentoの.htaccessの有効化を行ないます。
virtualdomain.conf内のmagentoを公開設定している <VirtualHost> ディレクティブ内に記述を追加します。

# cd /etc/httpd/conf.d
# vi virtualdomain.conf

・virtualdomain.conf

<Directory "/var/www/html/magento131">
	Options FollowSymLinks
	AllowOverride All
</Directory>
# /etc/rc.d/init.d/httpd configtest
Syntax OK
# /etc/rc.d/init.d/httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

phpのバージョンを確認します。

# cd /var/www/html
# vi phpinfo.php

・phpinfo.php

<?php
        phpinfo();
?>

http://localhost/phpinfo.php
PHPが最新のバージョンになっていることを確認します。(今回はPHP Version 5.2.9)

これでMagentoのインストール環境は整いました。
Magentoのインストールに続きます。