[[さくらのVPS]]

remiリポジトリを使って、最新バージョンのPHPをインストールします。

#contents

* PHPのインストール [#c28fd57b]
(参考)
http://www.natzworks.com/digital/2010/444.html

- 現状のバージョンを確認

 # rpm -qa | grep php | sort

- インストールできるPHPのバージョンを確認

 # yum info php --enablerepo=remi ← remi リポジトリを一時的に有効化

以下のような結果が表示された。

 Available Packages
 Name       : php
 Arch       : x86_64
 Version    : 5.3.6
 Release    : 1.el5.remi

- 最新のPHP 5.3.6があったので、これを入れる。

 # yum install php --enablerepo=remi

- date.timezoneを設定(PHPの処理が速くなる)
(参考)date.timezoneを設定するとPHPが早くなる
http://pentan.info/php/datetimezone_strict.html

viでPHPの設定ファイルを編集する。

 # vi /etc/php.ini

以下のように変更する。

 [Date]
 date.timezone = "Asia/Tokyo"

** PHPのライブラリをインストール [#ffb3c328]
(参考)
http://pentan.info/server/linux/php_yum.html

| php-mbstring | マルチバイト(日本語など)を扱う |
| php-gd | GDライブラリで画像を扱う |
| php-pear | PEARを使用する |
| php-mcrypt | 暗号化関数Mcryptを使用する(phpMyAdminで必要) |
| php-mysql | MySQLを使用する |
| php-devel | PHPのコンパイル(phpizeコマンド)を行う | 
| php-devel | PHPのコンパイル(phpizeコマンド)を行う |
| php-eaccelerator | アクセラレータ(APCを使う場合は、php-apc) |

上記のライブラリをyumコマンドでインストールする。

 # yum install php php-mbstring php-gd php-pear php-mcrypt
 php-mysql php-devel php-eaccelerator --enablerepo=remi
と、一行で入力しても良いがエラーが出たので、個別にインストールしてみる。

 # yum install php-mbstring --enablerepo=remi
 # yum install php-gd --enablerepo=remi
 # yum install php-pear --enablerepo=remi
 # yum install php-mcrypt --enablerepo=remi
 (# yum install php-mysql --enablerepo=remi) → エラーになる
 # yum install php-devel --enablerepo=remi

* eAccelerator [#e1edc30a]

** eAccelerator とは? [#w3fd2c75]
[[【Vine Linuxで自宅サーバー】eAcceleratorの導入(PHPの高速化)>http://vine.1-max.net/eAccelerator.html]]
>eAcceleratorとは、一度呼び出されたコンパイル済みのPHPスクリプトをキャッシュして実行速度を上げるソフトの事です。
一般にアクセラレーターと言われているものです。

** eAccelerator のインストール [#d08d5895]

 # yum install php-eaccelerator --enablerepo=remi

** eAcceleratorの設定 [#bfdda86f]
(参考)
http://butabuta30s.sblo.jp/article/42126929.html

eAcceleratorの設定ファイルを編集する。

 # vi /etc/php.d/eaccelerator.ini

以下のような内容に変更する。

 [eaccelerator]

 
 ;;;;;;;;;;;;;;;;;;;
 ; About this file ;
 ;;;;;;;;;;;;;;;;;;;
 ;
 ; eAccelerator is compatible with Zend Optimizer's loader. Zend Optimizer
 ; must be installed after eAccelerator in php.ini. If you don't use scripts
 ; encoded with Zend Encoder then we do not recommend you install Zend Optimizer
 ; with eAccelerator.
 
 ; You must uncomment one (and only one) line from the following to load
 ; eAccelerator extension.
 extension="eaccelerator.so"
 ;zend_extension="/usr/lib/php/modules/eaccelerator.so"
 ;zend_extension_ts="/usr/lib/php/modules/eaccelerator.so"
 
 ;extension="eaccelerator.dll"
 ;zend_extension_ts="c:\php4\eaccelerator.dll"
 ;zend_extension="c:\php4\eaccelerator.dll"
 
 ; The amount of shared memory (in megabytes) that eAccelerator will use.
 ; "0" means OS default. Default value is "0".
 eaccelerator.shm_size = "32" → とりあえず「0」を「32」にしておく
 
 ; The directory that is used for disk cache. eAccelerator stores precompiled
 ; code, session data, content and user entries  here. The same data can be
 ; stored in shared memory also (for more quick access). Default value is
 ; "/var/cache/php-eaccelerator".
 eaccelerator.cache_dir = "/var/cache/php-eaccelerator"
 
 ; Enables or disables eAccelerator. Should be "1" for enabling or
 ; "0" for disabling. Default value is "1".
 eaccelerator.enable = "1"
 
 ; Enables or disables internal peephole optimizer which may speed up code
 ; execution. Should be "1" for enabling or "0" for disabling.
 ; Default value is "1".
 eaccelerator.optimizer = "1"
 
 ; Enables or disables debug logging. Setting this to 1 will print information
 ; to the log file about the cach hits of a file.
 eaccelerator.debug = 0
 
 ; Set the log file for eaccelerator. When this option isn't set then the data
 ; will be logged to stderr
 eaccelerator.log_file = "/var/log/httpd/eaccelerator_log"
 
 ; A string that's prepended to all keys. This allows two applications that use the
 ; same key names to run on the same host by setting this in .htaccess or in the
main
 ; same key names to run on the same host by setting this in .htaccess or in the main
 ; configuration file for the whole webserver.
 eaccelerator.name_space = ""
 
 ; Enables or disables PHP file modification checking. Should be "1"
 ; for enabling or "0" for disabling. You should set it to "1" if you want
 ; to recompile PHP files after modification. Default value is "1".
 eaccelerator.check_mtime = "1"
 
 ; Determine which PHP files must be cached. You may specify the number of
 ; patterns (for example "*.php *.phtml") which specifies to cache or
 ; not to cache. If pattern starts with the character "!", it means to ignore
 ; files which are matched by the following pattern. Default value is "" that
 ; means - all PHP scripts will be cached.
 eaccelerator.filter = ""
 
 ; When eAccelerator fails to get shared memory for new script it removes
 ; all scripts which were not accessed at last "shm_ttl" seconds from shared
 ; memory. Default value is "0" that means - don't remove any files from
 ; shared memory.
 eaccelerator.shm_ttl = "0"
 
 ; When eAccelerator fails to get shared memory for new script it tries to
 ; remove old script if the previous try was made more then "shm_prune_period"
 ; seconds ago. Default value is "0" that means - don't try to remove any
 ; files from shared memory.
 eaccelerator.shm_prune_period = "0"
 
 ; Enables or disables caching of compiled scripts on disk. It has no effect
 ; on session data and content caching.
 ; Default value is "0" that means - use disk and shared memory for caching.
 eaccelerator.shm_only = "0"
 
 ; The script paths that are allowed to get admin information and do admin
 ; controls
 eaccelerator.allowed_admin_path = ""

- ディレクトリの確認(パーミッション)

 eaccelerator.cache_dir = "/var/cache/php-eaccelerator"
 eaccelerator.log_file = "/var/log/httpd/eaccelerator_log" ← ログ不要?

- Apache再起動で設定変更を反映

 # /etc/rc.d/init.d/httpd restart

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS