LoginSignup
4
2

More than 5 years have passed since last update.

Ubuntu16.04にPHP5.6を入れる

Last updated at Posted at 2018-07-10

概要

昔、Ubuntu16.04(WSL環境)に何かをしてPHP7からダウングレードした記憶があったのですが、具体的に何をしたのか覚えていなかったので、簡単にメモを起こしました。

前準備

調べた手順にならって作業をしました。

$ sudo add-apt-repository ppa:ondrej/php

ここで以下のようなエラーが出ました。

Cannot add PPA: 'ppa:~ondrej/ubuntu/php'.
ERROR: '~ondrej' user or team does not exist.

1つ1つやりましたが、自分の環境では、以下すべて終えたところで、$ sudo add-apt-repository ppa:ondrej/phpが初めて上手くいきました。

$ sudo apt remove --purge ca-certificates
$ sudo apt autoremove
$ sudo apt install ca-certificates
$ sudo apt install software-properties-common

上記を行って、再度実行し、updateします。

$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt-get update

目的のPHPのインストール

目的のPHPのインストールをします。

$ sudo apt install php5.6 php7.0

apache2を入れていて、こっちでも利用する予定なので、以下を追加でしました。

$ sudo apt install libapache2-mod-php5.6 libapache2-mod-php7.0

切替え

目的のバージョンに切り替えます。

$ sudo a2enmod php5.6
$ sudo apachectl restart
$ sudo update-alternatives --set php /usr/bin/php5.6
4
2
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
4
2