ubuntu安装php5

在最新的Ubuntu上安装的PHP版本为7,在新版本中部分函数被更换,所以导致有些时候使用php环境会报错,此时就需要安装php5的环境。

添加源

/etc/apt/sources.list文件中添加以下源

1
2
3
4
5
deb http://mirror.yandex.ru/debian wheezy main contrib
deb-src http://mirror.yandex.ru/debian wheezy main contrib

deb http://security.debian.org/ wheezy/updates main contrib
deb-src http://security.debian.org/ wheezy/updates main contrib

添加完成后更新安装

1
2
apt-get update 
apt-get install php5

注意

如果更新时遇到以下错误请添加相应公钥

1
2
W: GPG error: http://security.debian.org wheezy/updates InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 9D6D8F6BC857C906  NO_PUBKEY 8B48AD6246925553
W: GPG error: http://mirror.yandex.ru/debian wheezy Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 8B48AD6246925553 NO_PUBKEY 7638D0442B90D010 NO_PUBKEY 6FB2A1C265FFB764

执行下面安装

1
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 9D6D8F6BC857C906 8B48AD6246925553 7638D0442B90D010  6FB2A1C265FFB764