クライアントの環境がPHP5.3~だった場合のテスト環境を用意したいのですが、
Macのターミナルからyumでインストールしようとすると...
$ sudo yum install php53
[sudo] password for centos7:
読み込んだプラグイン:fastestmirror
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
mysql-connectors-community | 2.5 kB 00:00:00
mysql-tools-community | 2.5 kB 00:00:00
mysql55-community | 2.5 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/2): mysql55-community/x86_64/primary_db | 98 kB 00:00:00
(2/2): updates/7/x86_64/primary_db | 3.2 MB 00:00:01
Determining fastest mirrors
- base: mirror.fairway.ne.jp
- extras: centos.usonyx.net
- updates: mirror.nus.edu.sg
パッケージ php53 は利用できません。
エラー: 何もしません
と出てきてしまってインストールできません。
こういった場合は、パッケージではなく
ソースコード?からのインストール的な感じになるのでしょうか?
こういったあたり、まだ勉強不足で詳しくなく、
それ以前にそもそもPHP5.3はインストールできるのか、
といったところをご教示いただければ幸いです。
お手数ですが宜しくお願いいたします。
気になる質問をクリップする
クリップした質問は、後からいつでもMYページで確認できます。
またクリップした質問に回答があった際、通知やメールを受け取ることができます。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
回答3件
0
OSバージョンとの互換性も皆無とは言えないかも知れませんが、一番の要因は、CentOS7のyumの標準リポジトリがPHP5.3をサポートしていないということだと思います。
yumリポジトリを自力で修正も出来る様ですが、大変だし環境全体に影響すると厄介なので、phpenvの使用を検討してみてはいかがですか?
投稿2015/08/07 00:16
総合スコア5936
0
【前提】
VirtualBox5.0.0 へ CentOS7 をインストールし、初期設定を実施後に確認
http://ftp.jaist.ac.jp/pub/Linux/CentOS/7.1.1503/isos/x86_64/CentOS-7-x86_64-DVD-1503-01.iso
#今回のようにある程度試行錯誤が避けられない状況では、もし事情が許すのであればVirtualBoxのような仮想環境の上にOSをインストールし、成功した箇所までで一旦スナップショットを作成しておいてから作業すると、少ない労力で正解へたどり着くことができます。
【最初にご連携した情報】
phpenvで複数のPHPのバージョンを管理する
PHPは依存モジュールが非常に多く(ここまで多いとは知りませんでした…)、同じCentOS7とは言ってもベースとなる環境(イン ストール済みパッケージのバージョン)の違いによって必要な対応が変わって来る可能性があります。
そのためある程度の試行錯誤は避けられず、以下の手順で作業してもokameさんの環境ではエラーが発生するかも知れない事をご了承ください。
様々な情報が交錯しているので…以下の情報をミックスして対応しました。
非常にたくさんのページを参照し試行錯誤したので整理仕切れていないのですが、主に参考にしたページのリンクを下記に貼っておきます。
PHPコンパイルによる高性能のFastCGIウェブサーバー構築とチューニングに関す るお話し(2)
phpenv + php-buildでPHPを複数バージョン利用する方法
virtualbox(centos)でphpenv+php-buildインストールメモ(5.3,5.4変更確認ま で)
phpenvで複数バージョンのPHPをディレクトリ毎に設定する
phpenv+php-build環境によるphpバージョン管理
構築時の問題
makeするとライブラリが入っているのに /usr/lib/ld: cannot find と怒られる問題
mod_pythonをコンパイルしようとしてapxsのバグを見つけた
CentOS5.5にPHP5.3.3をインストールする
phpenvの導入して複数バージョンのPHPを管理する
【yumリポジトリ追加】
下記を参考に「EPEL/Remi/RepoForge」を追加
CentOS サーバー構築 リポジトリ管理
追加完了後にyumリポジトリを最新化
sudo yum update
【ビルド環境構築】
sudo yum -y install
autoconf
automake
libtool.x86_64
flex.x86_64
bison.x86_64
gcc.x86_64
gcc-c++.x86_64
make.x86_64
kernel-headers.x86_64
kernel-devel.x86_64
【依存パッケージインストール】
参考にした情報によって追加しているパッケージに微妙な違いがあるので、okameさんの環境に対しては過不足があるかもしれませんが…
sudo yum -y install \
libxml2-devel.x86_64
bzip2-devel.x86_64
libcurl-devel.x86_64
libpng-devel.x86_64
openjpeg-devel.x86_64
freetype-devel.x86_64
t1lib-devel.x86_64
libXpm-devel.x86_64
gd-devel.x86_64
gmp-devel.x86_64
libc-client-devel.x86_64
libicu-devel.x86_64
openldap-devel.x86_64
libmcrypt-devel.x86_64
mysql-devel.x86_64
readline-devel.x86_64
net-snmp-devel.x86_64
libtidy-devel.x86_64
libxslt-devel.x86_64
libmcrypt-devel.x86_64
libevent.x86_64
libevent-devel.x86_64
aspell-devel.x86_64
enchant-devel.x86_64
oniguruma-devel.x86_64
unixODBC-devel.x86_64
sqlite-devel.x86_64
krb5-devel.x86_64
【Apache-2.2.31 をインストール】
Apatche2.4系でも問題ないかもしれませんが、とりあえずApache2.2系の最新版で試してみました。
CentOSへApache2.xをソースビルドしてService登録する
Apache2.2をソースからインストールしてみる
apxsでapacheにモジュールを追加する
cd /usr/local/src
wget http://ftp.yz.yamagata-u.ac.jp/pub/network/apache//httpd/httpd-2.2.31.tar.gz
tar zxf httpd-2.2.31.tar.gz
cd httpd-2.2.31
./configure -prefix=/usr/local/apache2 \
-enable-so
-enable-rewrite
-enable-ssl
-enable-mods-shared=all
make
make install
自動起動設定等は、必要に応じて実施してください。
【bisonの Ver. 2.4.1 を localへインストール】
バージョンが新しすぎると警告が出るので、localにインストールします。
cd /usr/local/src
wget http://ftp.gnu.org/gnu/bison/bison-2.4.1.tar.gz
tar zxf bison-2.4.1.tar.gz
cd bison-2.4.1/
./configure
make
make install
【re2cをインストール】
cd /usr/local/src
wget http://jaist.dl.sourceforge.net/project/re2c/re2c/0.13.7.5/re2c-0.13.7.5.tar.gz
tar zxf re2c-0.13.7.5.tar.gz
cd re2c-0.13.7.5/
./configure
make
make install
【libevent-1.4-15をインストール】
cd /usr/local/src
wget http://sourceforge.net/projects/levent/files/libevent/libevent-1.4/libevent-1.4.15.tar.gz
tar zxf libevent-1.4.15.tar.gz
cd libevent-1.4.15
./configure
make
make install
echo "/usr/local/lib" >/etc/ld.so.conf.d/local_lib.conf
ldconfig
【libmcrypt-2.5.7をインストール】
cd /usr/local/src
wget ftp://ftp.linux.co.kr/etc/libmcrypt-2.5.7.tar.gz
tar zxf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7/libltdl
./configure --enable-ltdl-install
make
make install
make clean
ldconfig
【phpenvのインストール】
$ cd
$ mkdir -p repos/git
$ cd repos/git
$ git clone https://github.com/CHH/phpenv.git
$ cd phpenv/bin
$ ./phpenv-install.sh
$ cd
設定を .bashrc へ追記します。
$ cat <<'EOF' >>~/.bashrc
export PATH="~/.phpenv/bin:$PATH"
eval "$(phpenv init -)"
EOF
$ source ~/.bashrc
<インストール結果確認>
$ phpenv
rbenv 0.4.0-153-g3b6faa8
Usage: rbenv <command> [<args>]
Some useful rbenv commands are:
commands List all available rbenv commands
local Set or show the local application-specific Ruby version
global Set or show the global Ruby version
shell Set or show the shell-specific Ruby version
rehash Rehash rbenv shims (run this after installing executables)
version Show the current Ruby version and its origin
versions List all Ruby versions available to rbenv
which Display the full path to an executable
whence List all Ruby versions that contain the given executable
See `rbenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/sstephenson/rbenv#readme
$
【php-buildのインストール】
$ git clone https://github.com/CHH/php-build.git ~/.phpenv/plugins/php-build
$ cd ~/.phpenv/plugins/php-build
$ sudo sh install.sh
$ cd
<インストール結果確認>
$ php-build
usage: php-build [options] <definition> <prefix>
<definition> What release should be used, as well as release-specific
configuration. This is either the name of a builtin
definition file (as listed with --definitions) or a path
to the definition file.
<prefix> All built executables, configurations and libraries are
placed in this directory. It's created if it doesn't
exist.
--definitions Lists all available definitions and exit
-h|--help Display this help and exit
-i|--ini <env> php.ini to use. If <env> is a file then this file is
used, otherwise php.ini-<env> from the source
distribution is used. Defaults to "production".
--pear Install PEAR alongside of Pyrus (experimental)
-v|--version Display version information and exit
$
【インストール可能バージョン確認】
$ php-build --definitions
5.2.17
5.3.2
5.3.3
5.3.6
・・・
【設定ファイルの調整】
~/.phpenv/plugins/php-build/share/php-build/definitions/5.3.3 の先頭に設定追加します。
$ sed -i '1s,^,configure_option "--with-apxs2" "/usr/local/apache2/bin/apxs"\n,'
~/.phpenv/plugins/php-build/share/php-build/definitions/5.3.3
【PHP5.3.3 のインストール】
# リトライ時にはtmpディレクトリ配下をお掃除してください。
$ sudo rm -rf /tmp/php-build/source/5.3.3
$ phpenv install 5.3.3
↓下記エラーが出るので・・・(okameさんが遭遇されたエラー)
| BUILD ERROR |
Here are the last 10 lines from the log:
/tmp/php-build/source/5.3.3/ext/dom/node.c:1905:40: エラー: 不完全型のポインタへの間接参照
RETVAL_STRINGL((char *) buf->buffer->content, ret, 1);
^
/tmp/php-build/source/5.3.3/Zend/zend_API.h:545:20: 備考: in definition of macro ‘ZVAL_STRINGL’
const char *__s=(s); int __l=l;
^
/tmp/php-build/source/5.3.3/ext/dom/node.c:1905:5: 備考: in expansion of macro ‘RETVAL_STRINGL’
RETVAL_STRINGL((char *) buf->buffer->content, ret, 1);
^
make: *** [ext/dom/node.lo] エラー 1
【libxml2のパッチ当て】
$ cd /tmp
$ curl -O https://mail.gnome.org/archives/xml/2012-August/txtbgxGXAvz4N.txt
$ mv /tmp/txtbgxGXAvz4N.txt /tmp/php-patch.txt
$ cd /tmp/php-build/source/5.3.3
$ patch -p0 < /tmp/php-patch.txt
【クリアせずに再ビルド】
$ cd
$ phpenv install 5.3.3
[Info]: Loaded extension plugin
[Info]: Loaded apc Plugin.
[Info]: Loaded composer Plugin.
(途中省略)
[Success]: Built 5.3.3 successfully.
$
ということで、一応、コンパイルが成功しました。
下記の通り、CentOS7でもPHP5.3.3がインストールできました。
$ phpenv versions
5.3.3
$
あとは、開発環境を構築したいディレクトリ配下へ移動してPHPの切り替えをどうぞ。
$ phpenv local 5.3.3
$ phpenv versions
- 5.3.3 (set by /path/to/.php-version)
$ php --version
PHP 5.3.3 (cli) (built: Aug 30 2015 23:03:08)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
with Xdebug v2.2.7, Copyright (c) 2002-2015, by Derick Rethans
$
投稿2015/08/30 14:36
総合スコア5936
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
0
これ私も経験しましたが、結局CnetOS7でPHP5.3運用をあきらめました。
yumで弾かれるという事は、恐らく互換性の問題ではないかと・・・。
ライブラリ関連が大分変更されているのでyumでの旧バージョンインストールは出来ないのではないかと思います。
ソースコンパイルすれば可能かもしれませんが、データベース関連モジュールでエラーをはきそうな予感がします。
恐らくなんですが、サポートが切れているバージョンはこのOSで運用しないで下さいてきな仕様なのかもしれませんね。
投稿2015/08/06 23:13
総合スコア1158
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/08/06 23:32
2015/08/06 23:41
2015/08/06 23:51
2015/08/07 01:20
2015/08/07 09:58
2015/08/21 02:25 編集
2015/08/30 14:39
あなたの回答
tips
太字
斜体
打ち消し線
見出し
引用テキストの挿入
コードの挿入
リンクの挿入
リストの挿入
番号リストの挿入
表の挿入
水平線の挿入
プレビュー
質問の解決につながる回答をしましょう。 サンプルコードなど、より具体的な説明があると質問者の理解の助けになります。 また、読む側のことを考えた、分かりやすい文章を心がけましょう。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/08/07 09:58 編集
2015/08/08 08:07
2015/08/10 00:43
2015/08/10 12:07 編集
2015/08/30 14:13
2015/08/30 23:43