LoginSignup
6
6

More than 5 years have passed since last update.

PHP5.5 Source Install

Last updated at Posted at 2014-03-01

Goal

* PHP5.5をCentOSにソースからインストールする
* Apacheは2.4系がソースからインストールされている前提
* (mySQLをPDOを使って接続する前提でビルドする)

Preparation

$> uname -a
Linux *** 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

$> cat /etc/issue
CentOS release 6.5 (Final)
Kernel \r on an \m

$> /usr/local/apache/bin/apachectl -V | head -n 1
Server version: Apache/2.4.7 (Unix)

Manual

Download

## 
## http://php.net/downloads.php
## 上記URLから任意のバージョンのダウンロードURLを確認
## 過去バージョンをもってきたい場合は、ページ右カラムのOld archiveから
## (http://www.php.net/releases/)
## 

## root user
cd /usr/local/src
wget "http://museum.php.net/php5/php-5.5.4.tar.gz"
tar zxvf php-5.5.4.tar.gz
ls -l php-5.5.4

Build / Install

cd /usr/local/src/php-5.5.4

yum install libxml2-devel libcurl-devel libmcrypt-devel

./configure \
--prefix=/usr/local/php-5.5.4 \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-mysql=/usr/local/mysql \
--with-pdo-mysql=/usr/local/mysql \
--with-mysqli=mysqlnd \
--enable-mbstring \
--enable-libgcc \
--enable-pcntl \
--with-zlib \
--with-openssl \
--with-zlib \
--with-config-file-scan-dir=/usr/local/php-5.5.4/lib/conf.d

make
make test
make install

Check Install

ls -l /usr/local/php-5.5.4
/usr/local/php-5.5.4/bin/php -v
  # PHP 5.5.4 (cli) (built: Mar  1 2014 20:26:49)
  # Copyright (c) 1997-2013 The PHP Group
  # Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies

Other Initial Setup

シムリンク
  # /usr/local/php-5.5.4 => /usr/local/php
php.ini
LoadModule
  # Apacheにphpモジュールを組み込む
AddType
  # Apacheに.phpのファイルをphpアプリケーションとして認識させる
DirectoryIndex
  # http://example.com/でアクセスするとindex.phpが配置されていればそのプログラムをよびだすように設定
Apache再起動
cd /usr/local
ln -s php-5.5.4 php

cd /usr/local/src/php-5.5.4
cp -i php.ini-production /usr/local/php-5.5.4/lib/php.ini
vi /usr/local/php-5.5.4/lib/php.ini
  # date.timezone = 'Asia/Tokyo'
  # (エラー設定:本番用)(/var/log/php/error.logはapacheのユーザが書き込める必要あり)
  # error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
  # display_errors = Off
  # log_errors = On
  # error_log = /var/log/php/error.log

vi /usr/local/apache/conf/httpd.conf
  # コメントアウトまたは追加
  # LoadModule php5_module        modules/libphp5.so

## 
## Apacheでphpアプリを動かしたいvirtual hostに以下の設定を追加
## 
AddType application/x-httpd-php .php
DirectoryIndex index.php index.html

/usr/local/apache/bin/apachectl graceful

Others

mysql系インストールオプションをつけずにPHPビルドして、あとからPDOドライバをインストールしたい場合
* http://qiita.com/metheglin/items/d0bd108e72168b714014

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6