0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Ubuntu18.04でPHP5.6とPHP7.4を使いたかった時のメモ

Posted at

やりたいこと

  • Ubuntu18.04にphp5.6とphp7.4が動く環境を用意したい
  • phpenvやらphpbrew使えばなんとかなるっしょ!
  • Dockerは使わないものとする

phpenvで試してみる。

anyenvでインストールされたphpenvで試した。

# phpenv install 5.6.40

記録を取っていないが色々コケる。

先人達の歴史を調査

お、ちょうど良い記事見つけた。
[php][ubuntu]php7とphp5とphpenv - 釣り。IT屋。毎日爆釣。(2019-07-29)

結論:phpenvなんてものはなかった。 ローカルでPHP7を使っててPHP5.xも切り替えて使いたいとかいう場合はdockerでカレントをマウントして使え。

ワロタ。

phpbrew を使ってみる

参考になる資料
https://gist.github.com/marulitua/f8932064ec5bfe6a5be9fadac7c5a141

それでも色々コケる

phpbrewでPHP 7.4を入れるのにいろいろつまづいた

私の環境は

$ brew install openssl
$ brew install libxml2

以外にも

$ brew install curl
$ brew install libxslt
$ brew install libzip

が必要だった。

$ brew ls <パッケージ名>

でbrew installのインストール先を調べられるので
各位、PATHは変えて下さい。

$ export PATH="/home/linuxbrew/.linuxbrew/Cellar/openssl@1.1/1.1.1g/bin:$PATH"
$ export PATH="/home/linuxbrew/.linuxbrew/Cellar/libxml2/2.9.10_1/bin:$PATH"
$ export PATH="/home/linuxbrew/.linuxbrew/Cellar/curl/7.70.0/bin:$PATH"
$ export PATH="/home/linuxbrew/.linuxbrew/Cellar/libxslt/1.1.34_1/bin:$PATH"
$ export PATH="/home/linuxbrew/.linuxbrew/Cellar/libzip/1.6.1_1/bin:$PATH"

$ export PKG_CONFIG_PATH="/home/linuxbrew/.linuxbrew/Cellar/openssl@1.1/lib/pkgconfig"
$ export LDFLAGS="-L/home/linuxbrew/.linuxbrew/Cellar/openssl@1.1/lib"
$ export CPPFLAGS="-I/home/linuxbrew/.linuxbrew/Cellar/openssl@1.1/include"
$ export PHP_BUILD_CONFIGURE_OPTS="--with-openssl=$(brew --prefix openssl) --with-libxml-dir=$(brew --prefix libxml2) --with-curl=$(brew --prefix curl) --with-libxslt-config=$(brew --prefix libxslt) --with-libzip=$(brew --prefix libzip)"
Enjoy!

よし!

PHP5.6とPHP7.4が同居できているのかチェック

無事動作完了!

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?