memo.xight.org

日々のメモ

Debian Stretch に PHP5.6 と PHP7.0 を共存させる

Summary

Debian StretchのオフィシャルリポジトリにはPHP5.6が含まれていない。
packages.sury.org のPHP5.6のパッケージを利用して、PHP5.6, PHP7.0 の環境を共存させたい。

sury.orgのgpgキーを追加

$ sudo apt-get install apt-transport-https
$ curl https://packages.sury.org/php/apt.gpg | sudo apt-key add -

- /etc/apt/sources.list.d/deb.sury.org.list
[src]
deb https://packages.sury.org/php/ stretch main


php5.6, php7.0のインストール

$ sudo apt-get update
$ sudo apt-get install php5.6-cli php5.6-fpm php7.0-cli php7.0-fpm


/etc/nginx/site-available/site-with-php7.0

server {
	listen 8870 default_server;
	listen [::]:8870 default_server;
	server_name _;
	root /var/www/site-with-php7.0;
	index index.php;
	location / {
		include snippets/fastcgi-php.conf;
		fastcgi_pass unix:/run/php/php7.0-fpm.sock; # adjust for the listen setting discussed above
	}
}

/etc/nginx/site-available/site-with-php5.6

server {
	listen 8856 default_server;
	listen [::]:8856 default_server;
	server_name _;
	root /var/www/site-with-php5.6;
	index index.php;
	location / {
		include snippets/fastcgi-php.conf;
		fastcgi_pass unix:/run/php/php5.6-fpm.sock; # adjust for the listen setting discussed above
	}
}

シンボリックリンクの作成, nginxの再起動

$ ln -s ../sites-available/site-with-php5.6 /etc/nginx/sites-enabled
$ ln -s ../sites-available/site-with-php7.0 /etc/nginx/sites-enabled
$ systemctl reload nginx.service


via

pehapkari.cz - 2017-03-27 - Multiple PHP versions, the easy way
https://pehapkari.cz/blog/2017/03/27/multiple-php-versions-the-easy-way/