ubuntu 14.04 php7 install mbstring error
PHP 7 升级
在升级到 PHP 7 之后,网站访问速度果然提升了不少
不过在安装 PHP 的一些依赖的时候也出现了一些问题
比如在接下来要提到的依赖 php7.0-mbstring
遇到的问题
当我执行安装命令时出现了如下错误:
root@iZu1w7e9kaaZ:~# apt-get install php7.0-mbstring
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
php7.0-mbstring
0 upgraded, 1 newly installed, 0 to remove and 3 not upgraded.
Need to get 462 kB of archives.
After this operation, 1542 kB of additional disk space will be used.
Err http://ppa.launchpad.net/ondrej/php/ubuntu/ trusty/main php7.0-mbstring amd64 7.0.14-1+deb.sury.org~trusty+1
404 Not Found
E: Failed to fetch http://ppa.launchpad.net/ondrej/php/ubuntu/pool/main/p/php7.0/php7.0-mbstring_7.0.14-1+deb.sury.org~trusty+1_amd64.deb 404 Not Found
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
根据错误提示 404 Not Found 可以发现,这个应该是安装源的问题
解决问题
尝试重新安装一下 PHP 7 的安装源
首先是将现有的安装源移除:
sudo apt-get install python-software-properties
sudo ppa-purge ppa:ondrej/php-7.0
如果提示 ppa-purge command no found
可以使用以下命令将安装源移除:
rm /etc/apt/sources.list.d/ondrej*
然后就是再次安装 PHP 7 源:
LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
注意,我在这行命令前加了 LC_ALL=en_US.UTF-8
这是因为在解决这个问题的时候,引申出了另一个问题
当我在执行 add-apt-repository ppa:ondrej/php 时,遇到了以下错误:
gpg: keyring `/tmp/tmpms3yty2b/secring.gpg' created
gpg: keyring `/tmp/tmpms3yty2b/pubring.gpg' created
gpg: requesting key E5267A6C from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpms3yty2b/trustdb.gpg: trustdb created
gpg: key E5267A6C: public key "Launchpad PPA for Ond\xc5\x99ej Sur�" imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
self.run()
File "/usr/lib/python3.4/threading.py", line 868, in run
self._target(*self._args, **self._kwargs)
File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 687, in addkey_func
func(**kwargs)
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 370, in add_key
return apsk.add_ppa_signing_key()
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 261, in add_ppa_signing_key
tmp_export_keyring, signing_key_fingerprint, tmp_keyring_dir):
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 210, in _verify_fingerprint
got_fingerprints = self._get_fingerprints(keyring, keyring_dir)
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 202, in _get_fingerprints
output = subprocess.check_output(cmd, universal_newlines=True)
File "/usr/lib/python3.4/subprocess.py", line 609, in check_output
output, unused_err = process.communicate(inputdata, timeout=timeout)
File "/usr/lib/python3.4/subprocess.py", line 947, in communicate
stdout = _eintr_retry_call(self.stdout.read)
File "/usr/lib/python3.4/subprocess.py", line 491, in _eintr_retry_call
return func(*args)
File "/usr/lib/python3.4/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 92: ordinal not in range(128)
这个是 Locale 的设置问题,所以需求增加 LC_ALL=en_US.UTF-8 命令
最后就可以放心的从安装源更新依赖了
sudo apt-get update
sudo apt-get install php7.0-mbstring
参考链接
http://askubuntu.com/questions/741913/php7-0-dev-installation-fails-on-ubuntu-14-0-4